From b5d03801d21dd541373372d5d0d1b1dcb1de849c Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Mon, 4 Nov 2019 13:25:44 +0300 Subject: [PATCH] fixes #80 --- src/PublicApiGenerator/ApiGenerator.cs | 54 ++++--------------- src/PublicApiGenerator/CodeNormalizer.cs | 43 +++++++++++++++ .../Class_event_attributes.cs | 2 +- .../Class_modifiers.cs | 6 +-- .../Method_extensions.cs | 8 +-- src/PublicApiGeneratorTests/NullableTests.cs | 2 +- .../Property_visibility.cs | 4 +- .../Struct_readonly.cs | 5 +- 8 files changed, 67 insertions(+), 57 deletions(-) create mode 100644 src/PublicApiGenerator/CodeNormalizer.cs diff --git a/src/PublicApiGenerator/ApiGenerator.cs b/src/PublicApiGenerator/ApiGenerator.cs index 540e2a5..bc0dca2 100644 --- a/src/PublicApiGenerator/ApiGenerator.cs +++ b/src/PublicApiGenerator/ApiGenerator.cs @@ -9,7 +9,6 @@ using System.IO; using System.Linq; using System.Reflection; -using System.Text; using System.Text.RegularExpressions; using ICustomAttributeProvider = Mono.Cecil.ICustomAttributeProvider; using TypeAttributes = System.Reflection.TypeAttributes; @@ -60,15 +59,6 @@ static string RemoveUnnecessaryWhiteSpace(string publicApi) // TODO: Better handle namespaces - using statements? - requires non-qualified type names static string CreatePublicApiForAssembly(AssemblyDefinition assembly, Func shouldIncludeType, bool shouldIncludeAssemblyAttributes, string[] whitelistedNamespacePrefixes, AttributeFilter attributeFilter) { - var publicApiBuilder = new StringBuilder(); - var cgo = new CodeGeneratorOptions - { - BracingStyle = "C", - BlankLinesBetweenMembers = false, - VerbatimOrder = false, - IndentString = " " - }; - using (var provider = new CSharpCodeProvider()) { var compileUnit = new CodeCompileUnit(); @@ -99,17 +89,18 @@ static string CreatePublicApiForAssembly(AssemblyDefinition assembly, Func Add(this PublicApiGeneratorTests.Examples.Configurator configurator) where T : class { } @@ -65,4 +65,4 @@ public static class GenericExtensions } // ReSharper restore ClassNeverInstantiated.Global // ReSharper restore UnusedMember.Global -} \ No newline at end of file +} diff --git a/src/PublicApiGeneratorTests/NullableTests.cs b/src/PublicApiGeneratorTests/NullableTests.cs index 5f56f08..e1f57fe 100644 --- a/src/PublicApiGeneratorTests/NullableTests.cs +++ b/src/PublicApiGeneratorTests/NullableTests.cs @@ -31,7 +31,7 @@ public void Should_Annotate_VoidReturn() AssertPublicApi(typeof(VoidReturn), @"namespace PublicApiGeneratorTests.Examples { - public class static VoidReturn + public static class VoidReturn { public static void ShouldBeEquivalentTo(this object? actual, object? expected) { } } diff --git a/src/PublicApiGeneratorTests/Property_visibility.cs b/src/PublicApiGeneratorTests/Property_visibility.cs index 8335dad..c555e7f 100644 --- a/src/PublicApiGeneratorTests/Property_visibility.cs +++ b/src/PublicApiGeneratorTests/Property_visibility.cs @@ -1,4 +1,4 @@ -using PublicApiGeneratorTests.Examples; +using PublicApiGeneratorTests.Examples; using Xunit; namespace PublicApiGeneratorTests @@ -325,4 +325,4 @@ public class ClassWithProtectedInternalGetterPublicSetter // ReSharper restore UnusedMember.Local // ReSharper restore UnusedMember.Global // ReSharper restore ClassNeverInstantiated.Global -} \ No newline at end of file +} diff --git a/src/PublicApiGeneratorTests/Struct_readonly.cs b/src/PublicApiGeneratorTests/Struct_readonly.cs index 47c80a4..c4353ff 100644 --- a/src/PublicApiGeneratorTests/Struct_readonly.cs +++ b/src/PublicApiGeneratorTests/Struct_readonly.cs @@ -1,4 +1,3 @@ -using System; using PublicApiGeneratorTests.Examples; using Xunit; @@ -12,7 +11,7 @@ public void Should_output() AssertPublicApi( @"namespace PublicApiGeneratorTests.Examples { - public struct readonly ReadonlyStruct { } + public readonly struct ReadonlyStruct { } }"); } } @@ -25,4 +24,4 @@ namespace Examples } } // ReSharper restore ClassNeverInstantiated.Global -} \ No newline at end of file +}