Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format code with dotnet-format #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
116 changes: 59 additions & 57 deletions Decomposer/src/DecomposerConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,25 @@ internal static class Constants
public const string DecomposedMethodDeclaration =
GeneratedCodeAttributes
+ """
{{ return_type }}
{{ method_name }} ({ { for parameter in parameters }}
{{ parameter.type }}
{{ parameter.name }}
{{ if not loop.last }}, {{ endif }}
{{ endfor }})
{{ if has_generic_type_constraints }}
{{ for generic_type_constraint in generic_type_constraints }}
where
{{ generic_type_constraint.name }} : {{ type_constraint.constraint }}
{{ endfor }}
{{ endif }}
""";

public const string DecomposableAttributeFilename = "DecomposableAttribute.g.cs";
{ { return_type } }
{ { method_name } } ({ { for parameter in parameters } }
{ { parameter.type } }
{ { parameter.name } }
{ { if not loop.last } }, { { endif } }
{ { endfor } })
{ { if has_generic_type_constraints } }
{ { for generic_type_constraint in generic_type_constraints } }
where
{ { generic_type_constraint.name } } : { { type_constraint.constraint } }
{ { endfor } }
{ { endif } }
""";

public const string DecomposableAttributeDeclaration =
DecomposedInterfaceHeader
+ """
public const string DecomposableAttributeFilename = "DecomposableAttribute.g.cs";

public const string DecomposableAttributeDeclaration =
DecomposedInterfaceHeader
+ """
[global::System.AttributeUsage(global::System.AttributeTargets.Class | global::System.AttributeTargets.Struct | global::System.AttributeTargets.Interface | global::System.AttributeTargets.Assembly)]
public sealed class DecomposeAttribute : global::System.Attribute
{
Expand All @@ -100,32 +100,34 @@ public DecomposeAttribute(global::System.Type type, string @namespace = null) {
""";

public const string IComposedClassDeclaration = """
public partial class {{ class_name }} : { { for type_member_tuple in decomposed_from } }
IDecomposed <{{ decomposed_from.type }}>
{
{{ for type_member_tuple in decomposed_from }}
{{ if type_member_tuple.member.is_property }}
public
{{~ type_member_tuple.member.type }}
{{~ type_member_tuple.member.name }}
{{ get; }}
{{ elif type_member_tuple.member.is_method }}
public
{{ decomposed_from.type }}
{{ decomposed_from.member }} {{ get; }}
{{ endfor }}


public
{{ class_name }} ({ decomposed_from } decomposed)
{
{ decomposed_from } = decomposed;
}

public
{ decomposed_from }
{ decomposed_from }
{{ get; }}
public partial class {{ class_name }} : { { for type_member_tuple in decomposed_from } }
IDecomposed <{ { decomposed_from.type } }>
{
{ { for type_member_tuple in decomposed_from } }
{ { if type_member_tuple.member.is_property } }
public
{ { ~type_member_tuple.member.type } }
{ { ~type_member_tuple.member.name } }
{ { get; } }
{ { elif type_member_tuple.member.is_method } }
public
{ { decomposed_from.type } }
{ { decomposed_from.member } }
{ { get; } }
{ { endfor } }


public
{ { class_name } } ({ decomposed_from }
decomposed)
{
{ decomposed_from } = decomposed;
}

public
{ decomposed_from }
{ decomposed_from }
{ { get; } }
}
""";

Expand Down Expand Up @@ -158,18 +160,18 @@ public DecomposeAttribute(global::System.Type type, string @namespace = null) {
| SymbolDisplayMiscellaneousOptions.UseErrorTypeSymbolName
| SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier
| SymbolDisplayMiscellaneousOptions.IncludeNotNullableReferenceTypeModifier
);
internal const string AttributeName = "Decompose";
internal const string AttributeFullName = AttributeName + nameof(Attribute);
internal const string InterfaceNamePrefix = "I";
internal const string InterfaceSuffix = "Decomposition";
internal const string NamespaceSuffix = ".Decompositions";
internal const string SourceFileNameSuffix = ".Decompositions.g.cs";
internal const string GeneratedCodeAttributeName = "GeneratedCodeAttribute";
internal const string GeneratedCodeAttributeFullName =
$"System.Diagnostics.CodeAnalysis.{GeneratedCodeAttributeName}";
internal const string CompilerGeneratedAttributeFullName =
"System.Runtime.CompilerServices.CompilerGeneratedAttribute";
);

internal const string AttributeName = "Decompose";
internal const string AttributeFullName = AttributeName + nameof(Attribute);
internal const string InterfaceNamePrefix = "I";
internal const string InterfaceSuffix = "Decomposition";
internal const string NamespaceSuffix = ".Decompositions";
internal const string SourceFileNameSuffix = ".Decompositions.g.cs";
internal const string GeneratedCodeAttributeName = "GeneratedCodeAttribute";
internal const string GeneratedCodeAttributeFullName =
$"System.Diagnostics.CodeAnalysis.{GeneratedCodeAttributeName}";
internal const string CompilerGeneratedAttributeFullName =
"System.Runtime.CompilerServices.CompilerGeneratedAttribute";
}
}