Skip to content

MSBuild properties to analyzer config break in presence of newlines #43970

@chsienki

Description

@chsienki

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:

<PropertyGroup>
  <PropWithNewLine>this
is 
a
valid = property
  </PropWithNewLine>
</PropertyGroup>

would result in

is_global = true
msbuild_property.PropWithNewLine = this
is 
a
valid = property

This is true for semicolons too. These are common in msbuild as its the default combine character for a list

For example:

<ItemGroup>
  <Item1 Include="a" />
  <Item1 Include="b" />
  <Item1 Include="c" />
</ItemGroup>
<PropertyGroup>
  <Item1Combined>@(Item1)</Item1Combined>
</PropertyGroup>

Will result in

build_property.Item1Combined = a;b;c

In editorconfig ; is the comment character, meaning only a will be passed to the consumer.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions