-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[Bug]: GetType can still be called as property function, due to case-sensitive comparison #9967
Comments
Nice find! I can't believe that match is not case sensitive in the first place. |
Will the fix be considered a breaking change again? |
I'm inclined to say no--because "we already updated the documentation to say you can't do that" but it's definitely a concern. @baronfel do you have thoughts? |
Another possible fix would be to block access to System.Type references in general, rather than just GetType(). |
I'm inclined to say 'no' for the same reason - the justification for the breaking change notes that there is no broadly-known usage of GetType any longer, so I think the impact of this would be quite low. If we get any significant user feedback that it is in use we can of course add breaking change notices quite quickly and out-of-band of the MSBuild code itself. |
If there is a possibility of low usage, shall we put the change behind the changewave? |
I see :) We have the MSBUILDENABLEALLPROPERTYFUNCTIONS, so the need of changewave is lowered.
|
Does that InvalidOperationException also trigger for param == "System.String"? If so, that seems misguided. "System.String".ToString() == "System.String".GetType().FullName |
@KalleOlaviNiemitalo it was exactly the case. |
Oh, I assumed you had param == typeof(RuntimeType), thus typeof(RuntimeType).ToString() == typeof(RuntimeType).GetType().FullName. |
I imagine |
To be honest, I was thinking to leave it as it is, since it is in debug mode + the fix is prepared. |
Issue Description
#6769 supposedly prevented calling GetType() as a property function, but it does not recognize the name if written with different letter case, e.g.
gettype
.Steps to Reproduce
demo.proj:
dotnet msbuild demo.proj
Expected Behavior
Actual Behavior
Analysis
Perhaps a case-insensitive comparison here would fix it:
msbuild/src/Build/Evaluation/Expander.cs
Line 5287 in a4ecab3
Alternatively, compare the MemberInfo.Name string after the lookup, rather than the user-specified string. That might be a larger change, though.
Versions & Configurations
MSBuild version 17.9.6+a4ecab324 in .NET SDK 8.0.202
The text was updated successfully, but these errors were encountered: