Skip to content

[Bug]: GetType can still be called as property function, due to case-sensitive comparison #9967

Description

@KalleOlaviNiemitalo

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:

<Project>
  <PropertyGroup>
    <foo>aa</foo>
  </PropertyGroup>

  <Target Name="bb">
    <Message Importance="high" Text="$(foo.gettype().FullName)"/>
  </Target>
</Project>

dotnet msbuild demo.proj

Expected Behavior

$ dotnet msbuild demo.proj
MSBuild version 17.9.6+a4ecab324 for .NET
demo.proj(7,32): error MSB4185: The function "GetType" on type "System.String" is not available for execution as an MSBuild property function.

Actual Behavior

$ dotnet msbuild demo.proj
MSBuild version 17.9.6+a4ecab324 for .NET
  System.String

Analysis

Perhaps a case-insensitive comparison here would fix it:

return methodName != "GetType";

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions