You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System.Collections;publicstaticclassExtensionMethods{publicstaticintCount(thisIEnumerablesource){return5;}}
`ProblemClass.cs'
using System.Collections.Generic;using System.Linq;publicclassProblemClass{publicvoidProblemMethod(){intlen= Enumerable.Count(newList<string>{"ABC","DEF"}?)??0;}}
The decompiled code is not compilable.
When unchecking the decompiler option C# 6.0 / VS 2015: Decompile ?. and ?[] operators or the decompiler option C# 3.0 / VS 2008: Use extension method syntax the saved code in ProblemClass.cs will be compilable:
using System.Collections.Generic;using System.Linq;publicclassProblemClass{publicvoidProblemMethod(){IEnumerable<string>s=newList<string>{"ABC","DEF"};intlen=((s!=null)? Enumerable.Count(s):0);}}
Another manifestation of the error is that when switching the focus from the method to the class the decompiled code will change (gif):
Details
Product in use: ILSpy version 8.2.0.7535
Version in use: .NET version 6.0.28-servicing.24120.7+34a109148c7d8a2c8e6431e83e4bce5712dd8083
ICSharpCode.Decompiler.CSharp.Resolver.CSharpResolver.GetAllExtensionMethods will return different results when focusing on the method in contrast with when focusing on the class.
When focusing on the method the ICSharpCode.Decompiler.CSharp.Transforms.IntroduceExtensionMethodsCanTransformToExtensionMethodCall method will return false because of the method.Equals(or.GetBestCandidateWithSubstitutedTypeArguments()) subcondition.
The issue was found when trying to decompile Microsoft.Graph.Communications.Common.
The extension method causing the confusion is Microsoft.Graph.Communications.Common.Validator.Any:
/// <summary>/// Determines whether a sequence contains any elements./// </summary>/// <param name="source">The <see cref="T:System.Collections.IEnumerable" /> to check for emptiness.</param>/// <returns>/// <see langword="true" /> if the source sequence contains any elements; otherwise, <see langword="false" />./// </returns>publicstaticboolAny(thisIEnumerablesource){if(source==null){returnfalse;}return source.Cast<object>()?.Any((objectx)=>x!=null)==true;}
The methods failing to be correctly decompiled are Microsoft.Graph.Communications.Common.Transport.HttpRequestMessageExtensions.ToGraphRequestAsync<T> and Microsoft.Graph.Communications.Common.Transport.HttpResponseMessageExtensions.ToGraphResponseAsync<T>.
The text was updated successfully, but these errors were encountered:
Input code
Decompiled code
`ExtensionMethods.cs'
`ProblemClass.cs'
The decompiled code is not compilable.
When unchecking the decompiler option C# 6.0 / VS 2015: Decompile ?. and ?[] operators or the decompiler option C# 3.0 / VS 2008: Use extension method syntax the saved code in
ProblemClass.cs
will be compilable:Another manifestation of the error is that when switching the focus from the method to the class the decompiled code will change (gif):
Details
ICSharpCode.Decompiler.CSharp.Resolver.CSharpResolver.GetAllExtensionMethods
will return different results when focusing on the method in contrast with when focusing on the class.When focusing on the method the
ICSharpCode.Decompiler.CSharp.Transforms.IntroduceExtensionMethodsCanTransformToExtensionMethodCall
method will return false because of themethod.Equals(or.GetBestCandidateWithSubstitutedTypeArguments())
subcondition.The issue was found when trying to decompile Microsoft.Graph.Communications.Common.
The extension method causing the confusion is
Microsoft.Graph.Communications.Common.Validator.Any
:The methods failing to be correctly decompiled are
Microsoft.Graph.Communications.Common.Transport.HttpRequestMessageExtensions.ToGraphRequestAsync<T>
andMicrosoft.Graph.Communications.Common.Transport.HttpResponseMessageExtensions.ToGraphResponseAsync<T>
.The text was updated successfully, but these errors were encountered: