-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from earloc/fix/quality-gate
fix: quality gate
- Loading branch information
Showing
5 changed files
with
691 additions
and
684 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,106 @@ | ||
#pragma warning disable CA1812 // Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Localization; | ||
using My.Super.Special.Namespace; | ||
using Playground.Console.NoCodeGen; | ||
using Playground.Console.WithCodeGen; | ||
using Playground.Common; | ||
using Playground.Common.Groups; | ||
using Playground.Common.Groups.TypealizR; | ||
using Playground.Common.NoCodeGen; | ||
|
||
|
||
var services = new ServiceCollection(); | ||
services.AddLogging(); | ||
services.AddLocalization(); | ||
|
||
services.AddScoped(x => x.GetRequiredService<IStringLocalizer<Ressources>>().Typealize()); | ||
var provider = services.BuildServiceProvider(); | ||
using var scope = provider.CreateScope(); | ||
var typealized = scope.ServiceProvider.GetRequiredService<TypealizedRessources>(); | ||
|
||
Console.WriteLine(typealized.Messages.Info.Info1); | ||
Console.WriteLine(typealized.Messages.Info.Info2); | ||
Console.WriteLine(typealized.Messages.Info.Info3); | ||
Console.WriteLine(typealized.Questions.What_to_do); | ||
Console.WriteLine(typealized.Questions.What_to_do__now(DateTime.Now)); | ||
|
||
|
||
services.AddSingleton<Greeter, Greeter>(); | ||
|
||
var customNamespace = provider.GetRequiredService<IStringLocalizer<CustomNameSpace>>(); | ||
Console.WriteLine(customNamespace.Hello()); | ||
|
||
|
||
var greeter = provider.GetRequiredService<Greeter>(); | ||
|
||
greeter.SayHello("Arthur"); | ||
greeter.SayHelloPublic("Arthur"); | ||
|
||
var internalLocalizable = provider.GetRequiredService<IStringLocalizer<InternalClass>>(); | ||
Console.WriteLine(internalLocalizable.Hello__name("Arthur")); | ||
|
||
|
||
var publicLocalizable = provider.GetRequiredService<IStringLocalizer<PublicClass>>(); | ||
Console.WriteLine(publicLocalizable.Hello__name("Arthur")); | ||
|
||
|
||
var localize = internalLocalizable; | ||
|
||
var userName = "Arthur"; | ||
var today = DateOnly.FromDateTime(DateTimeOffset.Now.UtcDateTime); | ||
|
||
localize.Hello__user__it_is__today(userName, today); | ||
|
||
|
||
var groups = provider.GetRequiredService<IStringLocalizer<Ressources>>(); | ||
Console.WriteLine( | ||
groups.SomeDeeplyNestedThingCalledAfterAMonster_With_the__name("Chewbacca") | ||
); | ||
|
||
var typealizedGroups = groups.Typealize(); | ||
|
||
Console.WriteLine( | ||
typealizedGroups.Some.Deeply.Nested.Thing.Called.After.A.Monster.With_the__name("Chewbacca") | ||
); | ||
|
||
var without_Params_In_MethodNames = provider.GetRequiredService<IStringLocalizer<Without_Params_In_MethodNames>>(); | ||
|
||
Console.WriteLine( | ||
without_Params_In_MethodNames.Hello("Earth") | ||
); | ||
|
||
Console.WriteLine( | ||
without_Params_In_MethodNames.Goodbye("Arthur") | ||
); | ||
|
||
#pragma warning restore CA1812 // Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
var g = typealizedGroups; | ||
|
||
static void SomeMethod(IStringLocalizer<Ressources> L) | ||
{ | ||
//use L | ||
} | ||
|
||
SomeMethod(g.Localizer); | ||
|
||
|
||
Console.WriteLine( | ||
g.Some.Deeply.Nested.Thing.Called.After.A.Monster.It | ||
); | ||
|
||
Console.WriteLine( | ||
g.Some.Deeply.Nested.Thing.Called.After.A.Monster.With_the__name("Chewbacca") | ||
#pragma warning disable CA1812 // Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Localization; | ||
using My.Super.Special.Namespace; | ||
using Playground.Console.NoCodeGen; | ||
using Playground.Console.WithCodeGen; | ||
using Playground.Common; | ||
using Playground.Common.Groups; | ||
using Playground.Common.Groups.TypealizR; | ||
using Playground.Common.NoCodeGen; | ||
using System.Runtime.InteropServices; | ||
|
||
const string arthur = "Arthur"; | ||
const string chewbacca = "Chewbacca"; | ||
|
||
var services = new ServiceCollection(); | ||
services.AddLogging(); | ||
services.AddLocalization(); | ||
|
||
services.AddScoped(x => x.GetRequiredService<IStringLocalizer<Ressources>>().Typealize()); | ||
var provider = services.BuildServiceProvider(); | ||
using var scope = provider.CreateScope(); | ||
var typealized = scope.ServiceProvider.GetRequiredService<TypealizedRessources>(); | ||
|
||
Console.WriteLine(typealized.Messages.Info.Info1); | ||
Console.WriteLine(typealized.Messages.Info.Info2); | ||
Console.WriteLine(typealized.Messages.Info.Info3); | ||
Console.WriteLine(typealized.Questions.What_to_do); | ||
Console.WriteLine(typealized.Questions.What_to_do__now(DateTime.Now)); | ||
|
||
|
||
services.AddSingleton<Greeter, Greeter>(); | ||
|
||
var customNamespace = provider.GetRequiredService<IStringLocalizer<CustomNameSpace>>(); | ||
Console.WriteLine(customNamespace.Hello()); | ||
|
||
|
||
var greeter = provider.GetRequiredService<Greeter>(); | ||
|
||
greeter.SayHello(arthur); | ||
greeter.SayHelloPublic(arthur); | ||
|
||
var internalLocalizable = provider.GetRequiredService<IStringLocalizer<InternalClass>>(); | ||
Console.WriteLine(internalLocalizable.Hello__name(arthur)); | ||
|
||
|
||
var publicLocalizable = provider.GetRequiredService<IStringLocalizer<PublicClass>>(); | ||
Console.WriteLine(publicLocalizable.Hello__name(arthur)); | ||
|
||
|
||
var localize = internalLocalizable; | ||
|
||
var userName = arthur; | ||
var today = DateOnly.FromDateTime(DateTimeOffset.Now.UtcDateTime); | ||
|
||
localize.Hello__user__it_is__today(userName, today); | ||
|
||
|
||
var groups = provider.GetRequiredService<IStringLocalizer<Ressources>>(); | ||
Console.WriteLine( | ||
groups.SomeDeeplyNestedThingCalledAfterAMonster_With_the__name(chewbacca) | ||
); | ||
|
||
var typealizedGroups = groups.Typealize(); | ||
|
||
Console.WriteLine( | ||
typealizedGroups.Some.Deeply.Nested.Thing.Called.After.A.Monster.With_the__name(chewbacca) | ||
); | ||
|
||
var without_Params_In_MethodNames = provider.GetRequiredService<IStringLocalizer<Without_Params_In_MethodNames>>(); | ||
|
||
Console.WriteLine( | ||
without_Params_In_MethodNames.Hello("Earth") | ||
); | ||
|
||
Console.WriteLine( | ||
without_Params_In_MethodNames.Goodbye(arthur) | ||
); | ||
|
||
#pragma warning restore CA1812 // Type 'Program' can be sealed because it has no subtypes in its containing assembly and is not externally visible | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
var g = typealizedGroups; | ||
|
||
static void SomeMethod(IStringLocalizer<Ressources> L) | ||
{ | ||
//use L | ||
} | ||
|
||
SomeMethod(g.Localizer); | ||
|
||
|
||
Console.WriteLine( | ||
g.Some.Deeply.Nested.Thing.Called.After.A.Monster.It | ||
); | ||
|
||
Console.WriteLine( | ||
g.Some.Deeply.Nested.Thing.Called.After.A.Monster.With_the__name("Chewbacca") | ||
); |
Oops, something went wrong.