Browse Source

TypeSystemAstBuilder: Do not create references to System.MathF, if PI or E are not defined.

pull/1409/head
Siegfried Pammer 6 years ago
parent
commit
04910a8eb4
  1. 8
      ICSharpCode.Decompiler/CSharp/Syntax/TypeSystemAstBuilder.cs

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

@ -970,9 +970,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -970,9 +970,11 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
IType mathType;
if (isDouble)
mathType = compilation.FindType(typeof(Math));
else
mathType = compilation.FindType(new TopLevelTypeName("System", "MathF")).GetDefinition()
?? compilation.FindType(typeof(Math));
else {
mathType = compilation.FindType(new TopLevelTypeName("System", "MathF")).GetDefinition();
if (mathType == null || !mathType.GetFields(f => f.Name == "PI" && f.IsConst).Any() || !mathType.GetFields(f => f.Name == "E" && f.IsConst).Any())
mathType = compilation.FindType(typeof(Math));
}
expr = TryExtractExpression(mathType, type, constantValue, "PI", isDouble)
?? TryExtractExpression(mathType, type, constantValue, "E", isDouble);

Loading…
Cancel
Save