New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CallExtensionMethodAsExtensionAnalyzer: ArgumentException #1018
Comments
I see this in my build pipeline, when running the tests. Which is odd, since the test project doesn't include CodeCracker... |
Hello, I just had the same exception. The problem was
probably because changing it to |
I just got the same issue! The first two extension methods here trigger it: namespace Something
{
using System;
using System.Management;
/// <summary>Extension methods for <see cref="ManagementBaseObject"/>.</summary>
internal static class ManagementBaseObjectExtensions
{
/// <summary>Tries to get the value of a property.</summary>
/// <typeparam name="TProperty">The type of the value to retrieve.</typeparam>
/// <param name="managementObject">The object of which to retrieve the value from.</param>
/// <param name="propertyName">The name of the property to retrieve.</param>
/// <returns>The property value, if it exists, otherwise <see langword="null"/>.</returns>
public static TProperty? TryGetPropertyValue<TProperty>(this ManagementBaseObject managementObject, string propertyName)
where TProperty : class
{
try
{
return (TProperty?)managementObject.Properties[propertyName]?.Value;
}
catch (ManagementException)
{
return null;
}
}
/// <summary>Tries to get the value of a property.</summary>
/// <typeparam name="TProperty">The type of the value to retrieve.</typeparam>
/// <param name="managementObject">The object of which to retrieve the value from.</param>
/// <param name="propertyName">The name of the property to retrieve.</param>
/// <returns>The property value, if it exists, otherwise <see langword="null"/>.</returns>
public static TProperty? TryGetPropertyStructValue<TProperty>(this ManagementBaseObject managementObject, string propertyName)
where TProperty : struct
{
try
{
return (TProperty?)managementObject.Properties[propertyName]?.Value;
}
catch (ManagementException)
{
return null;
}
}
/// <summary>Tries to get the <see cref="DateTime"/> value of a property.</summary>
/// <param name="managementObject">The object of which to retrieve the value from.</param>
/// <param name="propertyName">The name of the property to retrieve.</param>
/// <returns>The property value, if it exists, otherwise <see langword="null"/>.</returns>
public static DateTime? TryGetDateTime(this ManagementBaseObject managementObject, string propertyName)
{
var dmtfDate = managementObject.TryGetPropertyValue<string>(propertyName);
return dmtfDate == null ? (DateTime?)null : ManagementDateTimeConverter.ToDateTime(dmtfDate);
}
}
} That is with .NET Standard 2.1, nullable reference types enabled. I think in this case it's due to the generic constraint and/or the nullable reference type? |
Got the same one and the problem was with method Fails: Enumerable.SequenceEqual(first.OrderBy(x => x), second.OrderBy(x => x)) Works: first.OrderBy(x => x).SequenceEqual(second.OrderBy(x => x)) Funny that both versions works, but |
Analyzer 'CodeCracker.CSharp.Usage.CallExtensionMethodAsExtensionAnalyzer' threw an exception of type 'System.ArgumentException' with message 'Inconsistent syntax tree features
Parameter name: trees'.
Started after we migrated to .net core 2.2. Have no idea where exactly it happens
The text was updated successfully, but these errors were encountered: