Skip to content
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

New feature: Throwaway (out) parameters in MSBuild property functions #41828

Open
Forgind opened this issue Jul 18, 2024 · 2 comments
Open

New feature: Throwaway (out) parameters in MSBuild property functions #41828

Forgind opened this issue Jul 18, 2024 · 2 comments
Assignees
Labels

Comments

@Forgind
Copy link
Member

Forgind commented Jul 18, 2024

Describe the issue or suggestion

With dotnet/msbuild#10209, we now permit users to use functions with out parameters and ref parameters as long as they don't care about the values that come out of them. Specifically, if a parameter is specified by '_', it will look for any method with the right name from the right assembly and try to match based on number of parameters. If there are multiple options, it will throw; if there is only one, it will execute it after tweaking all the _ to have the right type.

Example:
$([System.Int32]::TryParse("3", _))

Limitation:
This tries to infer which method overload of TryParse (or other function) to use, but if there are multiple overloads that could equally well fit the provided parameters and underscores, this will fail to determine definitively which function to use and will throw an error instead. This includes if a method currently has no conflicting overloads, and a new overload is added, which means a customer may see a breaking change in updating the version of an assembly in which the version update adds a new overload for a method they invoke that is indistinguishable from the method they intend to use. (I think this is very unlikely to occur, but it theoretically could.)

@JanKrivanek
Copy link
Member

The request is for changing this article: https://learn.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2022#calling-instance-methods-on-static-properties

@rainersigwald
Copy link
Member

Please hold on this, I'm backing out the MSBuild change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants