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
{ {
AstType mathAstType = ConvertType(mathType); AstType mathAstType = ConvertType(mathType);
var fieldRef = new MemberReferenceExpression(new TypeReferenceExpression(mathAstType), memberName); var fieldRef = new MemberReferenceExpression(new TypeReferenceExpression(mathAstType), memberName);
if (AddResolveResultAnnotations) if (AddResolveResultAnnotations) {
fieldRef.WithRR(new MemberResolveResult(mathAstType.GetResolveResult(), mathType.GetFields(f => f.Name == memberName).Single())); var field = mathType.GetFields(f => f.Name == memberName).FirstOrDefault();
if (field != null) {
fieldRef.WithRR(new MemberResolveResult(mathAstType.GetResolveResult(), field));
}
}
if (type.IsKnownType(KnownTypeCode.Double)) if (type.IsKnownType(KnownTypeCode.Double))
return fieldRef; return fieldRef;
if (mathType.Name == "MathF") if (mathType.Name == "MathF")

Loading…
Cancel
Save