diff --git a/src/PublicApiGenerator/CodeNormalizer.cs b/src/PublicApiGenerator/CodeNormalizer.cs index 0da3064..92a6366 100644 --- a/src/PublicApiGenerator/CodeNormalizer.cs +++ b/src/PublicApiGenerator/CodeNormalizer.cs @@ -65,6 +65,7 @@ public static string NormalizeGeneratedCode(StringWriter writer) gennedClass = gennedClass.Replace("struct " + READONLY_MARKER, "readonly struct "); gennedClass = gennedClass.Replace(READONLY_MARKER, string.Empty); // remove magic marker from readonly struct ctor gennedClass = Regex.Replace(gennedClass, @"\r\n|\n\r|\r|\n", Environment.NewLine); + gennedClass = Regex.Replace(gennedClass, @$"{Environment.NewLine}\s+;{Environment.NewLine}", ";" + Environment.NewLine); // bug-fix for https://github.com/PublicApiGenerator/PublicApiGenerator/issues/301 gennedClass = RemoveUnnecessaryWhiteSpace(gennedClass); return gennedClass; diff --git a/src/PublicApiGeneratorTests/Assembly_attributes.cs b/src/PublicApiGeneratorTests/Assembly_attributes.cs index 4286023..2b2d2f6 100644 --- a/src/PublicApiGeneratorTests/Assembly_attributes.cs +++ b/src/PublicApiGeneratorTests/Assembly_attributes.cs @@ -7,8 +7,8 @@ [assembly: AttributeWithPositionalParameters1("Hello")] [assembly: AttributeWithPositionalParameters2(42)] [assembly: AttributeWithMultiplePositionalParameters(42, "Hello")] -[assembly: AttributeWithNamedParameterAttribute(StringValue = "Hello", IntValue = 42)] -[assembly: ComVisibleAttribute(false)] +[assembly: AttributeWithNamedParameter(StringValue = "Hello", IntValue = 42)] +[assembly: ComVisible(false)] namespace PublicApiGeneratorTests { @@ -17,7 +17,10 @@ public class Assembly_attributes : ApiGeneratorTestsBase [Fact] public void Attributes() { -#if NET8_0 +#if NET472 + const string TFM = ".NETFramework,Version=v4.7.2"; + const string TFMNAME = ".NET Framework 4.7.2"; +#elif NET8_0 const string TFM = ".NETCoreApp,Version=v8.0"; const string TFMNAME = ".NET 8.0"; #elif NET7_0 diff --git a/src/PublicApiGeneratorTests/Issue301.cs b/src/PublicApiGeneratorTests/Issue301.cs new file mode 100644 index 0000000..f79a23c --- /dev/null +++ b/src/PublicApiGeneratorTests/Issue301.cs @@ -0,0 +1,101 @@ +using PublicApiGeneratorTests.Examples; + +namespace PublicApiGeneratorTests +{ + public class Issue301 : ApiGeneratorTestsBase + { + [Fact] + public void Should_Render_Semicolon_Properly_1() + { + AssertPublicApi(typeof(Interface1), +""" +namespace PublicApiGeneratorTests.Examples +{ + public interface Interface1 + { + void ConfigureMapping() + where T : class; + } +} +"""); + } + + [Fact] + public void Should_Render_Semicolon_Properly_2() + { + AssertPublicApi(typeof(Interface2), +""" +namespace PublicApiGeneratorTests.Examples +{ + public interface Interface2 + { + void ConfigureMapping() + where T : class; + } +} +"""); + } + + [Fact] + public void Should_Render_Semicolon_Properly_3() + { + AssertPublicApi(typeof(Interface3), +""" +namespace PublicApiGeneratorTests.Examples +{ + public interface Interface3 + { + void ConfigureMapping() + where T : class; + } +} +"""); + } + + [Fact] + public void Should_Render_Semicolon_Properly_4() + { + AssertPublicApi(typeof(Interface4), +""" +namespace PublicApiGeneratorTests.Examples +{ + public interface Interface4 + { + void ConfigureMapping() + where T : class + where K : struct; + } +} +"""); + } + } + + + namespace Examples + { + public interface Interface1 + { + void ConfigureMapping() + where T : class; + } + + public interface Interface2 + { + void ConfigureMapping() + where T : class; + } + + public interface Interface3 + { + void ConfigureMapping() + where T : class; + } + + public interface Interface4 + { + void ConfigureMapping() + where T : class + where K : struct; + } + } +} diff --git a/src/PublicApiGeneratorTests/PublicApiGeneratorTests.csproj b/src/PublicApiGeneratorTests/PublicApiGeneratorTests.csproj index 84c500b..23232b5 100644 --- a/src/PublicApiGeneratorTests/PublicApiGeneratorTests.csproj +++ b/src/PublicApiGeneratorTests/PublicApiGeneratorTests.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1;net6.0;net7.0;net8.0 + netcoreapp3.1;net6.0;net7.0;net8.0;net472 $(NoWarn);CS0618;CS0067;CS8597;CS8603;CS8618;CS8653;IDE0051;IDE0060;IDE1006