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

Immutable Properties #848

Closed
kingces95 opened this issue Aug 1, 2016 · 1 comment
Closed

Immutable Properties #848

kingces95 opened this issue Aug 1, 2016 · 1 comment
Labels
Area: Language Issues impacting the MSBuild programming language. triaged

Comments

@kingces95
Copy link

I ran across a bug where I unintentionally defined a property with the same name as another property defined in a target file I included. It would be nice if msbuild had facilities to help detect this type of issue. For instance, if I could have somehow marked my property immutable then msbuild could have issued an error when the property was subsequently overwritten in the imported target file.

One possible way to mark properties as immutable would be via an IsReadOnly attribute applied to property and propertyGroup elements. Also, it would also be nice to be able to change the default to readonly via, possibly, a ReadOnlyProperties attribute applied on the Project element.

There is already a mechanism by which command line properties are treated as immutable. Maybe that same logic could be used to enforce a new readonly property feature. That logic would have to be extended to issue an error instead of silently failing after attempting to update the property as is currently the case for command line properties. I'd like to see an error in that case as well. Possibly enabled via an environment variable ala MSBuildWarnOnUninitializedProperty but MSBuildWarnOnWriteToCommandLineProperty.

Warm regards,
Chris

@rainersigwald rainersigwald added the Area: Language Issues impacting the MSBuild programming language. label Feb 9, 2017
@rainersigwald
Copy link
Member

I accidentally duplicated this as #1673, and it appears to have gotten a bit more commentary so I'm going to unify by moving this comment to that thread. Great idea, though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Language Issues impacting the MSBuild programming language. triaged
Projects
None yet
Development

No branches or pull requests

3 participants