Skip to content

Adds nkJSObject.DotNetVersionFixups for dotnet 10.0#19

Open
squarebananas wants to merge 1 commit intonkast:mainfrom
squarebananas:DotNet10Fixups
Open

Adds nkJSObject.DotNetVersionFixups for dotnet 10.0#19
squarebananas wants to merge 1 commit intonkast:mainfrom
squarebananas:DotNet10Fixups

Conversation

@squarebananas
Copy link
Copy Markdown
Contributor

Adds a nkJSObject.DotNetVersionFixups function to apply dotnet 10.0 fixups.

Calling this function allows net10.0 to be added as a target framework for the nkast.Wasm projects and Kni.BlazorGL. It does so by adding back the removed Module, BINDING.conv_string and Blazor.platform.getArrayLength definitions, but only if they are missing. This means no changes will occur to the original implementations when using net8.0.

In the case of Kni, adding window.nkJSObject.DotNetVersionFixups(); at the beginning of the existing window.initRenderJS function in index.html will ensure the fixups are in place at startup. I have added this to nkJSObject as this serves as a base object for most things, however this could be moved to another location if preferred.

Associated Kni GitHub discussion post:
kniEngine/kni#2541

@nkast
Copy link
Copy Markdown
Owner

nkast commented Apr 5, 2026

I don't see what else we can do with Module, until we remove .net8 and replace this inplace.
On the long run, I expect that this will not live in a global, and we have to pass it as an argument on every function. But right now, blazor support one WASM module per page.

The only place we use BINDING.conv_string
is in nkJSObject.ReadString(...)

var str = BINDING.conv_string(pt);

Is it possible to inline the code there, assuming it works on both .net8 and .net10 ?

For getArrayLength(...) my plan was to pass the length from the C# side, but that will require some time.

@squarebananas
Copy link
Copy Markdown
Contributor Author

On the long run, I expect that this will not live in a global, and we have to pass it as an argument on every function.

What would the reason for that be, compared to say having it accessible by window.nkJSObject.Module or something?

Is it possible to inline the code there, assuming it works on both .net8 and .net10 ?

Yeah. I had it so that all the original net8.0 implementations would not be replaced for now though. Mainly for testing that everything works as expected when switching between net8 and net10. I can just replace that if you prefer though.

For getArrayLength(...) my plan was to pass the length from the C# side, but that will require some time.

I can sort a PR for that if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants