Browse Source

TSAB: Fix exception in special constant handling in case minimal corlib is used.

pull/1423/head
Siegfried Pammer 6 years ago
parent
commit
0a4c1dfd41
  1. 6
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

6
ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

@ -742,7 +742,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -742,7 +742,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
expression = null;
if (!specialConstants.TryGetValue(constant, out var info))
return false;
if (!UseSpecialConstants) {
// if the field definition cannot be found, do not generate a reference to the field.
var field = type.GetFields(p => p.Name == info.Member).SingleOrDefault();
if (!UseSpecialConstants || field == null) {
// +Infty, -Infty and NaN, cannot be represented in their encoded form.
// Use an equivalent arithmetic expression instead.
if (info.Type == KnownTypeCode.Double) {
@ -800,7 +802,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -800,7 +802,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
expression = new MemberReferenceExpression(expression, info.Member);
if (AddResolveResultAnnotations)
expression.AddAnnotation(new MemberResolveResult(new TypeResolveResult(type), type.GetFields(p => p.Name == info.Member).Single()));
expression.AddAnnotation(new MemberResolveResult(new TypeResolveResult(type), field));
return true;
}

Loading…
Cancel
Save