Skip to content
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
75 changes: 39 additions & 36 deletions InterfaceGenerator/src/InterfaceGeneratorConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ public static class Constants
""";

public const string GenerateInterfaceAttributeDeclaration = $$$"""
{{{Header}}}
{{{Header
}}}

[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
public sealed class {{{GenerateInterfaceAttribute}}}(Type? @type = default, string? interfaceName, string? @namespace) : Attribute
{
public type Type { get; } = @type;
public string InterfaceName { get; } = interfaceName;
public string Namespace { get; } = @namespace;
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)]
public sealed class {{ { GenerateInterfaceAttribute} }}(Type ? @type = default, string? interfaceName, string? @namespace) : Attribute
{
public type Type { get; } = @type;
public string InterfaceName { get; } = interfaceName;
public string Namespace { get; } = @namespace;
}
""";

Expand All @@ -63,44 +64,46 @@ public sealed class {{{GenerateInterfaceAttribute}}}(Type? @type = default, stri

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 = "{{ full_definition }};";

public static readonly Scriban.Template MethodDeclarationTemplate = Scriban.Template.Parse(
MethodDeclaration
);

public const string MethodParameter = """
{{ type }} {{ name }}
""";
);

public const string MethodDeclaration = "{{ full_definition }};";

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 }} {{ if is_indexed }}this[ {{ indexers }}] {{ else }} {{ name }} {{ end }} { {{ if is_gettable }} get; {{ end }} {{ if is_settable }} set; {{ end }} }";

public static readonly Scriban.Template PropertyDeclarationTemplate = Scriban.Template.Parse(
PropertyDeclaration
);

public static readonly SymbolDisplayFormat SymbolDisplayFormat =
new(
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
memberOptions: SymbolDisplayMemberOptions.IncludeParameters,
parameterOptions: SymbolDisplayParameterOptions.None
);

public const string PropertyDeclaration =
"{{ type }} {{ if is_indexed }}this[ {{ indexers }}] {{ else }} {{ name }} {{ end }} { {{ if is_gettable }} get; {{ end }} {{ if is_settable }} set; {{ end }} }";

public static readonly Scriban.Template PropertyDeclarationTemplate = Scriban.Template.Parse(
PropertyDeclaration
);

public static readonly SymbolDisplayFormat SymbolDisplayFormat =
new(
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
memberOptions: SymbolDisplayMemberOptions.IncludeParameters,
parameterOptions: SymbolDisplayParameterOptions.None
);
// new(
// globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Included,
// typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
Expand Down