-
Notifications
You must be signed in to change notification settings - Fork 5k
WASM-compilation breaks Microsoft.CodeAnalysis #114950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@VYDocuWare It is an exception raised inside Roslyn codebase. You can wrap your JSExport method with try-catch to get more details [JSExport]
static bool GetCompiledResult()
{
try
{
var expressionOutcome = ExpressionProcessor.ProcessExpression();
return expressionOutcome.IsSpeculativeSemanticModel;
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex}");
return false;
}
} |
Thanks. I pushed the try/catch and a simplifying change to the reproduction-repository. Here's the error I now get:
I see it's due to the below code in ExpressionProcessor.cs: var compilation = VisualBasicCompilation.Create("TemporaryCompilation",
syntaxTrees: new[] { tree },
references: new[]
{
MetadataReference.CreateFromFile(typeof(Microsoft.VisualBasic.Constants).Assembly.Location),
MetadataReference.CreateFromFile(typeof(System.Diagnostics.Debug).Assembly.Location),
MetadataReference.CreateFromFile(Assembly.Load("System.Runtime, Version=6.0.0.0").Location),
}); I actually need these references, as I can't validate my code without them. Any help? |
With #111642, there is probably going to be an easier way to do this in .NET 10. |
Thanks. I now load the .dlls separately, and it seems to work. I pushed the code to the repository. However, from my understanding, this will cause the browser to fetch the .dlls every time there's a validation request. Is there a way to load the .dlls once, and then reuse them across all the validation requests? That is, can I "store" the .dlls someplace accessible to the validator, and have it check for them? |
Also, I've noticed that the WASM Expression Validator works in the main browser thread, causing it to block when running. Is there a way to make it run in a separate thread, without using web workers myself? |
WasmSharp has a global metadata reference cache that it stores all the metadata references in.
Not that I know of - however it's been a while since I last looked into any of this (including e.g multi-threaded WASM). |
If you set |
How can I make use of this in my own project? |
It's more complicated that it sounds - its just a static readonly List<MetadataReference> References With a wrapper class around it. |
Uh oh!
There was an error while loading. Please reload this page.
Description
Hello. I've created a project, which makes use of Microsoft.CodeAnalysis, and I compile it to WASM using
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
However, when I start RoslynWebAssembly/bin/Release/net9.0/browser-wasm/AppBundle/main.js in a browser environment, I get the following error:
Uncaught ManagedError: Argument_EmptyString Arg_ParamName_Name, path at sn (marshal-to-js.ts:420:18) at gn (managed-exports.ts:316:15) at Object.<anonymous> (invoke-cs.ts:321:17) at main.js:12:50
Any help?
Reproduction Steps
Here's a reproduction of the non-working project: https://github.com/VYDocuWare/RoslynWebAssembly
Expected behavior
The wasm-compiled method returns "IsSpeculativeSemanticModel", which is my test of whether the SemanticModel has been generated.
Actual behavior
I get the following error:
Uncaught ManagedError: Argument_EmptyString Arg_ParamName_Name, path at sn (marshal-to-js.ts:420:18) at gn (managed-exports.ts:316:15) at Object.<anonymous> (invoke-cs.ts:321:17) at main.js:12:50
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: