Skip to content

Commit 8dd8763

Browse files
committed
Allow project properties to specify custom comment
This can help workaround the issue of the value having invalid content for an XML summary element (i..e. the value has XML). Further fixes #390
1 parent 6ea45bd commit 8dd8763

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/ThisAssembly.Project/ThisAssembly.Project.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</ItemGroup>
2525
<ItemGroup>
2626
<!-- Collect requested properties, and eval their value -->
27-
<Constant Include="@(ProjectPropertyDistinct -> 'Project.%(Identity)')" Value="$(%(ProjectPropertyDistinct.Identity))" Root="." />
27+
<Constant Include="@(ProjectPropertyDistinct -> 'Project.%(Identity)')" Value="$(%(ProjectPropertyDistinct.Identity))" Comment="%(ProjectPropertyDistinct.Comment)" Root="." />
2828
</ItemGroup>
2929
</Target>
3030

src/ThisAssembly.Project/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ them as `ProjectProperty` MSBuild items in the project file, such as:
1111
</PropertyGroup>
1212
<ItemGroup>
1313
<!-- Opt-in to emitting that property value as a constant in ThisAssembly.Project -->
14-
<ProjectProperty Include="Foo" />
14+
<ProjectProperty Include="Foo" Comment="This comment replaces the default comment :)" />
1515
</ItemGroup>
1616
```
1717

src/ThisAssembly.Tests/Tests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ with a newline and
3939
// Some comments too.
4040
""".ReplaceLineEndings(), ThisAssembly.Project.Multiline.ReplaceLineEndings());
4141

42+
[Fact]
43+
public void CanUseProjectFullFileContents()
44+
{
45+
Assert.NotEmpty(ThisAssembly.Project.ProjectFile);
46+
Assert.False(ThisAssembly.Project.ProjectFile.StartsWith("|"));
47+
}
48+
4249
[Fact]
4350
public void CanUseConstants()
4451
=> Assert.Equal("Baz", ThisAssembly.Constants.Foo.Bar);

src/ThisAssembly.Tests/ThisAssembly.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<!--<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>-->
2121
<NoWarn>CS0618;CS8981;TA100;$(NoWarn)</NoWarn>
2222
<PackageScribanIncludeSource>false</PackageScribanIncludeSource>
23+
<ProjectFile>$([System.IO.File]::ReadAllText($(MSBuildProjectFullPath)))</ProjectFile>
2324
</PropertyGroup>
2425

2526
<Import Project="..\*\ThisAssembly*.props" />
@@ -66,6 +67,7 @@
6667
<ProjectProperty Include="Foo" />
6768
<ProjectProperty Include="Description" />
6869
<ProjectProperty Include="Multiline" />
70+
<ProjectProperty Include="ProjectFile" Comment="Full project contents" />
6971
<Constant Include="Foo.Raw" Value="$(Multiline)" Comment="$(Multiline)" />
7072
<Constant Include="Foo.Bar" Value="Baz" Comment="Yay!" />
7173
<Constant Include="Foo.Hello" Value="World" Comment="Comments make everything better 😍" />

0 commit comments

Comments
 (0)