From 83b8704cb88523976d33ed66f1fc135c317b7aa5 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 10:04:29 +0000 Subject: [PATCH] style: format code with dotnet-format Format code with dotnet-format This commit fixes the style issues introduced in 2b44475 according to the output from dotnet-format. Details: https://app.deepsource.com/gh/dgmjr-io/InterfaceGenerator/transform/99d0488a-4e71-487e-a467-835094d368d8/ --- src/Constants.cs | 78 +++++++++++++++++++++------------------ src/InterfaceGenerator.cs | 7 ++-- 2 files changed, 46 insertions(+), 39 deletions(-) diff --git a/src/Constants.cs b/src/Constants.cs index 6b3d989..6e8cf5f 100644 --- a/src/Constants.cs +++ b/src/Constants.cs @@ -35,18 +35,18 @@ public static class Constants """ using System; - [AttributeUsage(AttributeTargets.Interface)] - internal sealed class GenerateInterfaceAttribute : Attribute - { - public Type Type { get; } - - public GenerateInterfaceAttribute (Type type) - { - { - Type = type; - } - } - } + [AttributeUsage(AttributeTargets.Interface)] +internal sealed class GenerateInterfaceAttribute : Attribute +{ + public Type Type { get; } + + public GenerateInterfaceAttribute(Type type) + { + { + Type = type; + } + } +} """; public const string InterfaceDeclaration = @@ -63,33 +63,39 @@ public GenerateInterfaceAttribute (Type type) namespace {{ namespace }} { - public partial interface {{ interface_name }} - { - {{ members }} - } + public partial interface {{ interface_name +} +} +{ + { { members } } +} } """; - public static readonly Scriban.Template InterfaceDeclarationTemplate = Scriban.Template.Parse(InterfaceDeclaration); - - public const string MethodDeclaration = - """ - {{ return_type }} {{ method_name }}({{ parameters }}) {{ type_constraints }}; - """; - - public static readonly Scriban.Template MethodDeclarationTemplate = Scriban.Template.Parse(MethodDeclaration); - - public const string MethodParameter = - """ - {{ type }} {{ name }} - """; - - public static readonly Scriban.Template MethodParameterTemplate = Scriban.Template.Parse(MethodParameter); - - public const string PropertyDeclaration = - """ - {{ type }} {{ name }} { {{~ if is_gettable ~}} get; {{~ end ~}} {{~ if is_settable ~}} set; {{~ end ~}} } - """; + public static readonly Scriban.Template InterfaceDeclarationTemplate = Scriban.Template.Parse(InterfaceDeclaration); + +public const string MethodDeclaration = +""" + { { return_type } } +{ { method_name } } ({ { parameters } }) { { type_constraints } }; +"""; + + public static readonly Scriban.Template MethodDeclarationTemplate = Scriban.Template.Parse(MethodDeclaration); + +public const string MethodParameter = +""" + { { type } } +{ { name } } +"""; + + public static readonly Scriban.Template MethodParameterTemplate = Scriban.Template.Parse(MethodParameter); + +public const string PropertyDeclaration = +""" + { { type } } +{ { name } } +{ { { ~ if is_gettable ~} } get; { { ~end ~} } { { ~ if is_settable ~} } set; { { ~end ~} } } +"""; public static readonly Scriban.Template PropertyDeclarationTemplate = Scriban.Template.Parse(PropertyDeclaration); diff --git a/src/InterfaceGenerator.cs b/src/InterfaceGenerator.cs index 226e3f2..66ddaad 100644 --- a/src/InterfaceGenerator.cs +++ b/src/InterfaceGenerator.cs @@ -87,9 +87,10 @@ protected static void Generate(SourceProductionContext context, ImmutableArray<( (tp.HasReferenceTypeConstraint ? "class" : "") + (tp.HasValueTypeConstraint ? "struct" : "") + Join(", ", tp.ConstraintTypes.Select(ct => ct.ToDisplayString())) + - (tp.HasConstructorConstraint ? "new()" : "").Trim() : ""))}" : ""))))))); - } - } + (tp.HasConstructorConstraint ? "new()" : "").Trim() : ""))} + " : ""))))))); + } +} }