Skip to content

Commit

Permalink
Add missing constant for AssemblyDescriptionAttribute
Browse files Browse the repository at this point in the history
Fixes #234
  • Loading branch information
kzu committed May 9, 2023
1 parent 2728d3e commit ea48dc5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/ThisAssembly.AssemblyInfo/AssemblyInfoGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class AssemblyInfoGenerator : IIncrementalGenerator
nameof(AssemblyCompanyAttribute),
nameof(AssemblyCopyrightAttribute),
nameof(AssemblyTitleAttribute),
nameof(AssemblyDescriptionAttribute),
nameof(AssemblyProductAttribute),
nameof(AssemblyVersionAttribute),
nameof(AssemblyInformationalVersionAttribute),
Expand Down
25 changes: 25 additions & 0 deletions src/ThisAssembly.Tests/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;

public static class Extensions
{
public static string ReplaceLineEndings(this string input) => ReplaceLineEndings(input, Environment.NewLine);

public static string ReplaceLineEndings(this string input, string replacementText)
{
#if NET6_0_OR_GREATER
return input.ReplaceLineEndings(replacementText);
#else
// First normalize to LF
var lineFeedInput = input
.Replace("\r\n", "\n")
.Replace("\r", "\n")
.Replace("\f", "\n")
.Replace("\x0085", "\n")
.Replace("\x2028", "\n")
.Replace("\x2029", "\n");

// Then normalize to the replacement text
return lineFeedInput.Replace("\n", replacementText);
#endif
}
}
5 changes: 5 additions & 0 deletions src/ThisAssembly.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public void CanReadResourceFile()
public void CanUseInfo()
=> Assert.Equal("ThisAssembly.Tests", ThisAssembly.Info.Title);

[Fact]
public void CanUseInfoDescription()
=> Assert.Equal(@"A Description
with a newline".ReplaceLineEndings(), ThisAssembly.Info.Description.ReplaceLineEndings());

[Fact]
public void CanUseConstants()
=> Assert.Equal("Baz", ThisAssembly.Constants.Foo.Bar);
Expand Down
4 changes: 3 additions & 1 deletion src/ThisAssembly.Tests/ThisAssembly.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Description>A Description
with a newline</Description>
<TargetFramework Condition="'$(BuildingInsideVisualStudio)' == 'true'">net472</TargetFramework>
<RootNamespace>ThisAssemblyTests</RootNamespace>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
Expand Down

0 comments on commit ea48dc5

Please sign in to comment.