ScarletKuro / Blazor.WebAssembly.DynamicCulture

Blazor.WebAssembly.DynamicCulture.Loader is a powerful tool that simplifies the process of loading multiple localization satellite assemblies simultaneously during startup in Blazor WebAssembly applications. With this tool, there's no need to manually refresh the page in order to access the new resource assembly.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Do you update this project to .Net7?

IngoManthey opened this issue · comments

I get follow hints by compile it:
3>EntityFrameworkPaginate -> C:\Users\ingo\source\repos\TipBlazor\EntityFrameworkPaginate\bin\Debug\net7.0\EntityFrameworkPaginate.dll
2>C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture.Loader\WebAssemblyCultureProvider.cs(75,32,79,18): warning CS0618: "IJSUnmarshalledRuntime.InvokeUnmarshalled<T0, T1, T2, TResult>(string, T0, T1, T2)" ist veraltet: "This method is obsolete. Use JSImportAttribute instead."
2>C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture.Loader\WebAssemblyCultureProvider.cs(84,26,88,18): warning CS0618: "IJSUnmarshalledRuntime.InvokeUnmarshalled<T0, T1, T2, TResult>(string, T0, T1, T2)" ist veraltet: "This method is obsolete. Use JSImportAttribute instead."
2>Blazor.WebAssembly.DynamicCulture.Loader -> C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture.Loader\bin\Debug\net7.0\Blazor.WebAssembly.DynamicCulture.Loader.dll
2>Erstellen des Projekts Blazor.WebAssembly.DynamicCulture.Loader.csproj beendet.
5>------ Neues Erstellen gestartet: Projekt: Blazor.WebAssembly.DynamicCulture, Konfiguration: Debug Any CPU ------
5>C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture\LanguageTrackProvider.cs(18,27,18,36): warning BL0007: Component parameter 'Blazor.WebAssembly.DynamicCulture.LanguageTrackProvider.Component' should be auto property
5>Blazor.WebAssembly.DynamicCulture -> C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture\bin\Debug\net7.0\Blazor.WebAssembly.DynamicCulture.dll

I will look, but interesting that Microsoft just pragma that in their own provider
https://github.com/dotnet/aspnetcore/blob/main/src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyCultureProvider.cs#L77
I use the same code with some modification.
I will add net7.0, but I guess I will do the same as MS for now and pragma it, because JSImport is only available for net 7.0. And currently I want to support both net6.0 and net7.0

For me it is also important that the components run under .Net 6. Thanks

I pushed changes to fix the BL0007 warrning
I haven't pushed the nuget package yet, but this adds a breaking change.
Now instead of this

<LanguageTrackProvider Component="this"/>

you need to do it like this

<LanguageTrackProvider OnInitializeEvent="provider => provider.RegisterComponent(this)"/>

I haven't found a better way, and this was recommended pattern from MS.

Hi,
I now use their Nuget libraries 1.1.0.
I change the code to:

But I get follow warnings:
Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand
Warnung RZ2012 Component 'LanguageTrackProvider' expects a value for the parameter 'Component', but a value may not have been provided. TipBlazor.Components C:\Users\ingo\source\repos\TipBlazor\TipBlazor.Components\Pages\Index.razor 19

What can I do?

If I start the WASM console have follow exception:
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Object of type 'Blazor.WebAssembly.DynamicCulture.LanguageTrackProvider' does not have a property matching the name 'OnInitializeEvent'.
System.InvalidOperationException: Object of type 'Blazor.WebAssembly.DynamicCulture.LanguageTrackProvider' does not have a property matching the name 'OnInitializeEvent'.
at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.ThrowForUnknownIncomingParameterName(Type targetType, String parameterName)
at Microsoft.AspNetCore.Components.Reflection.ComponentProperties.SetProperties(ParameterView& parameters, Object target)
at Microsoft.AspNetCore.Components.ParameterView.SetParameterProperties(Object target)
at Microsoft.AspNetCore.Components.ComponentBase.SetParametersAsync(ParameterView parameters)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)

This is in my .Net7 Project

I change the code to:
<LanguageTrackProvider OnInitializeEvent="provider => provider.RegisterComponent(this)" />

Sorry, I published the 2.0.0 package in nuget only now that includes the change with the

<LanguageTrackProvider OnInitializeEvent="provider => provider.RegisterComponent(this)"/>

I tried to experiment with this

C:\Users\ingo\source\repos\TipBlazor\DynamicCulture\Blazor.WebAssembly.DynamicCulture.Loader\WebAssemblyCultureProvider.cs(75,32,79,18): warning CS0618: "IJSUnmarshalledRuntime.InvokeUnmarshalled<T0, T1, T2, TResult>(string, T0, T1, T2)" ist veraltet: "This method is obsolete. Use JSImportAttribute instead."

for the net7.0 and do something like this

#if NET7_0_OR_GREATER
[JSImport("Blazor._internal.getSatelliteAssemblies")]
public static partial int GetSatelliteAssemblies(string[] assemblies);

[JSImport("Blazor._internal.readSatelliteAssemblies")]
public static partial byte[] ReadSatelliteAssemblies();
#endif

but this doesn't work, because getSatelliteAssemblies requires a pointer of the dotnet array not an js string[] which is not supported by the JSImportAttribute, so yeah the net7.0 will use the obsolete method until Microsoft will support this.

Then let's leave it like that. I'll install the 2.0.0 version right away. Thank you for your help.