-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
MSBuild properties to analyzer config break in presence of newlines #43970
Comments
I think the simplest solution would be to transform the values via something well-known, and special case transforming them back inside the compiler. My current thinking is to base64encode the values in the config file, and special case |
base64 will be a significant obfuscation, which will make some build failure investigations much harder (like the one that led me to file a dupe bug of this in the first place). If instead you applied URI-encoding to any .editorconfig-reserved character as msbuild itself does to xml-reserved chars, then most values will appear in plaintext, and only those characters that require special treatment will be obfuscated. |
Just hit this in #64917. The only workaround is splitting with |
I have found an alternative (though not pretty). Use |
The EditorConfig spec was updated so that https://spec.editorconfig.org/#no-inline-comments Specification was updated in editorconfig/specification#31 Also related to #44596 #51625 will handle the The case of multiline still needs work. |
This is a problem caused by the implementation of AnalyzerConfig.Parse method. This method assumes that analyzer configuration is given by an EditorConfig style file. The MSBuild documentation states that property values can also be given in XML format, but if they are multi-line, they will not be passed to analyzer correctly. The EditorConfig specification cannot be controlled by Microsoft or .NET community. Note: This does not mean that we can write analyzer configurations in the new file format. As a workaround for the moment, analyzer configurations with multi-line values could be given by AdditionalFiles for that purpose, rather than through project files. |
I just stumbled on this while trying to improve EmbeddedResourceGenerator by using the embedded resource As already mentioned in this issue, the generated editorconfig is problematic and the last part ( [~/EmbeddedResourceGenerator/EmbeddedResourceAccessGenerator.Tests/2InvalidChars-\;.txt]
build_metadata.EmbeddedResource.LogicalName = EmbeddedResourceAccessGenerator.Tests.2InvalidChars-;.txt Is there any chance that this problem will ever be solved? |
We transform MSBuild properties to global analyzer configs via the
GenerateMSBuildAnalyzerConfig
task.In MSBuild it's permissible for properites to contain newlines, which transfers into the resulting config, breaking downstream parsing.
For example:
would result in
This is true for semicolons too. These are common in msbuild as its the default combine character for a list
For example:
Will result in
In editorconfig
;
is the comment character, meaning onlya
will be passed to the consumer.The text was updated successfully, but these errors were encountered: