Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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