Browse Source

Fix InvalidOperationException in TSAB.MakeFieldReference() when a System.Math field could not be found

pull/1556/head
Daniel Grunwald 6 years ago
parent
commit
fe4a80ec6c
  1. 8
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

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

@ -1086,8 +1086,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -1086,8 +1086,12 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
{
AstType mathAstType = ConvertType(mathType);
var fieldRef = new MemberReferenceExpression(new TypeReferenceExpression(mathAstType), memberName);
if (AddResolveResultAnnotations)
fieldRef.WithRR(new MemberResolveResult(mathAstType.GetResolveResult(), mathType.GetFields(f => f.Name == memberName).Single()));
if (AddResolveResultAnnotations) {
var field = mathType.GetFields(f => f.Name == memberName).FirstOrDefault();
if (field != null) {
fieldRef.WithRR(new MemberResolveResult(mathAstType.GetResolveResult(), field));
}
}
if (type.IsKnownType(KnownTypeCode.Double))
return fieldRef;
if (mathType.Name == "MathF")

Loading…
Cancel
Save