Skip to content

Commit ea48dc5

Browse files
committed
Add missing constant for AssemblyDescriptionAttribute
Fixes #234
1 parent 2728d3e commit ea48dc5

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

src/ThisAssembly.AssemblyInfo/AssemblyInfoGenerator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class AssemblyInfoGenerator : IIncrementalGenerator
2121
nameof(AssemblyCompanyAttribute),
2222
nameof(AssemblyCopyrightAttribute),
2323
nameof(AssemblyTitleAttribute),
24+
nameof(AssemblyDescriptionAttribute),
2425
nameof(AssemblyProductAttribute),
2526
nameof(AssemblyVersionAttribute),
2627
nameof(AssemblyInformationalVersionAttribute),
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
3+
public static class Extensions
4+
{
5+
public static string ReplaceLineEndings(this string input) => ReplaceLineEndings(input, Environment.NewLine);
6+
7+
public static string ReplaceLineEndings(this string input, string replacementText)
8+
{
9+
#if NET6_0_OR_GREATER
10+
return input.ReplaceLineEndings(replacementText);
11+
#else
12+
// First normalize to LF
13+
var lineFeedInput = input
14+
.Replace("\r\n", "\n")
15+
.Replace("\r", "\n")
16+
.Replace("\f", "\n")
17+
.Replace("\x0085", "\n")
18+
.Replace("\x2028", "\n")
19+
.Replace("\x2029", "\n");
20+
21+
// Then normalize to the replacement text
22+
return lineFeedInput.Replace("\n", replacementText);
23+
#endif
24+
}
25+
}

src/ThisAssembly.Tests/Tests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ public void CanReadResourceFile()
1717
public void CanUseInfo()
1818
=> Assert.Equal("ThisAssembly.Tests", ThisAssembly.Info.Title);
1919

20+
[Fact]
21+
public void CanUseInfoDescription()
22+
=> Assert.Equal(@"A Description
23+
with a newline".ReplaceLineEndings(), ThisAssembly.Info.Description.ReplaceLineEndings());
24+
2025
[Fact]
2126
public void CanUseConstants()
2227
=> Assert.Equal("Baz", ThisAssembly.Constants.Foo.Bar);

src/ThisAssembly.Tests/ThisAssembly.Tests.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
<PropertyGroup>
44
<IsPackable>false</IsPackable>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net7.0</TargetFramework>
6+
<Description>A Description
7+
with a newline</Description>
68
<TargetFramework Condition="'$(BuildingInsideVisualStudio)' == 'true'">net472</TargetFramework>
79
<RootNamespace>ThisAssemblyTests</RootNamespace>
810
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

0 commit comments

Comments
 (0)