Skip to content

Commit

Permalink
Merge pull request #210 from nielsNocore/aditionalXmlCommentsChanges
Browse files Browse the repository at this point in the history
aditional XML Comment changes

forced merge due to sonarscanner breaking the build and publishing a new pre-release
  • Loading branch information
earloc authored May 14, 2024
2 parents 7256a46 + e600473 commit 08fd65d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ public string ToCSharp(Type generatorType) => $$"""
namespace Microsoft.Extensions.Localization
{

{{generatorType.GeneratedCodeAttribute()}}
/// <summary>
/// Extensions for <see cref="{{markertType.FullName}}"/> to utilize typed-access to ressources generated by TypealizR.
/// </summary>
{{generatorType.GeneratedCodeAttribute()}}
{{markertType.Accessibility.ToVisibilty().ToString().ToLowerInvariant()}} static partial class IStringLocalizerExtensions{{markertType.FullNameForClassName}}
{

{{methods.Select(x => x.ToCSharp()).ToMultiline()}}

/// <summary>
/// wraps the specified <see cref="IStringLocalizer{{markertType.Name}}"/> into a generated type providing properties to access [Some.Nested.Group]: via properties
/// wraps the specified <see cref="IStringLocalizer{{{markertType.Name}}}"/> into a generated type providing properties to access [Some.Nested.Group]: via properties
/// IStringLocalizer{{{markertType.Name}}} localize = ...
/// localize.Some.Nested.Group...
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ public TypealizedClassModel(string typeName, TypeModel markerType, string rootNa

[SuppressMessage("Globalization", "CA1308:Normalize strings to uppercase", Justification = "uppercase would not be valid C#")]
public string ToNestedCsharp(Type generatorType, string indent) => $$"""

{{indent}} /// <summary>
{{indent}} /// Nested class created to provide grouped translations.
{{indent}} /// </summary>
{{indent}}{{generatorType.GeneratedCodeAttribute()}}
{{indent}}{{markerType.Accessibility.ToVisibilty().ToString().ToLowerInvariant()}} partial class {{typeName}}Group
{{indent}}{

{{indent}} private readonly IStringLocalizer<{{markerType.GlobalFullName}}> localizer;

{{indent}} /// <summary>
{{indent}} /// Creates a new instance of <see cref="{{typeName}}Group"/>
{{indent}} /// </summary>
{{indent}} [DebuggerStepThrough]
{{indent}} public {{typeName}}Group(IStringLocalizer<{{markerType.GlobalFullName}}> localizer)
{{indent}} {
Expand All @@ -53,7 +60,7 @@ public string ToNestedCsharp(Type generatorType, string indent) => $$"""

{{indent}} {{members.Select(x => x.ToCSharp()).ToMultiline($" ")}}
{{indent}}
{{groups.Select(x => $"{indent} public {x.typeName}Group {x.typeName} {{ get; }}").ToMultiline(appendNewLineAfterEach: false)}}
{{groups.Select(x => GroupedPropertyToCsharp(x, indent)).ToMultiline(appendNewLineAfterEach: false)}}
{{groups.Select(x => x.ToNestedCsharp(generatorType, $"{indent} ")).ToMultiline(appendNewLineAfterEach: false)}}

{{indent}}}
Expand All @@ -65,14 +72,12 @@ public string ToCSharp(Type generatorType) => $$"""
{{Usings.Select(x => $"using {x};").ToMultiline(appendNewLineAfterEach: false)}}
namespace {{markerType.Namespace}}.TypealizR
{

{{generatorType.GeneratedCodeAttribute()}}
/// <summary>
/// Wraps a <see cref="IStringLocalizer{T}"/> and provides properties for typed-access to resources, generated by TypealizR
/// Wraps a <see cref="IStringLocalizer{{{markerType.Name}}}"/> and provides properties for typed-access to resources, generated by TypealizR
/// </summary>
{{generatorType.GeneratedCodeAttribute()}}
{{markerType.Accessibility.ToVisibilty().ToString().ToLowerInvariant()}} partial class {{typeName}}
{

private readonly IStringLocalizer<{{markerType.GlobalFullName}}> localizer;
/// <summary>
Expand All @@ -85,7 +90,7 @@ namespace {{markerType.Namespace}}.TypealizR
}
{{members.Select(x => x.ToCSharp()).ToMultiline(" ")}}

{{groups.Select(x => $" public {x.typeName}Group {x.typeName} {{ get; }}").ToMultiline(appendNewLineAfterEach: false)}}
{{groups.Select(x => GroupedPropertyToCsharp(x, " ")).ToMultiline(appendNewLineAfterEach: false)}}

{{groups.Select(x => x.ToNestedCsharp(generatorType, " ")).ToMultiline(appendNewLineAfterEach: false)}}

Expand Down Expand Up @@ -114,11 +119,19 @@ namespace {{markerType.Namespace}}.TypealizR
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures) => this.localizer.GetAllStrings(includeParentCultures);

/// <summary>
/// The wrapped <see cref="IStringLocalizer{T}"/>
/// The wrapped <see cref="IStringLocalizer{{{markerType.Name}}}"/>
/// </summary>
/// <returns>The wrapped <see cref="IStringLocalizer{T}"/>.</returns>
/// <returns>The wrapped <see cref="IStringLocalizer{{{markerType.Name}}}"/>.</returns>
public IStringLocalizer<{{markerType.GlobalFullName}}> Localizer => this.localizer;
}
}
""";

private static string GroupedPropertyToCsharp(TypealizedClassModel propertyType, string indent) => $$"""

{{indent}}/// <summary>
{{indent}}/// Gets the {{propertyType.typeName}} translator group.
{{indent}}/// </summary>
{{indent}}public {{propertyType.typeName}}Group {{propertyType.typeName}} { get; }
""";
}

0 comments on commit 08fd65d

Please sign in to comment.