Closed JasonBock closed 3 years ago
Forgot to mention this project started from this issue - I'm hoping this issue will close that one.
Sounds like the generator here depends on the WebAssembly.dll
assembly. Given that the load is failing here that means it's almost certainly not being passed with the /analyzer
flag. That's a requiurement for all analyzer and their dependent DLLs.
@jaredpar you're correct in that WebAssembly.Generator
references WebAssembly
. But WebAssembly
is just a NuGet package, it's not referenced by WebAssembly.IntegrationTests
(and I don't think it should be either).
@jaredpar wait....I'm looking at this sample, and it seems like you have to do a fair amount to reference another package (basically, everything after line 13). Are all of those settings and entries necessary? Meaning, you just can't do a simple <PackageReference>
in a SG-based project; you need to set up more than that?
@jaredpar OK, I tried some things, and it's still not working, nor is it generating the NuGet package either. I'm kind of stumped, not sure what I'm missing....
I got this working here: https://github.com/jmarolf/generator-start/tree/webassembly-dependency
My best guess is that some of the packages you are including are messing up with nuget packaging as I understand it. the only real difference bewteen mine and yours is that
@jmarolf I looked at what you did....but what I'm not seeing is how the WebAssembly.IntegrationTests
projects references WebAssembly.Generators
in a way such that it's running the generators. When I added:
OutputItemType="Analyzer"
to the project reference, I get the same error that I'm seeing in my code.
At this point, I think I'm going to revisit how this is doing what it's doing. Maybe a better way is to write a .NET tool and let it generate the .cs file based on a given .wasm file. Your comment in Discord about how you have a concern about perf since WebAssembly
has to load the .wasm file itself is also a reason I'm considering the change.
ah, you want this to work as a project reference not just a nuget package. one sec let me go look up the msbuild goop
adding <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
will deploy all the dependencies to the output directory. as I've done here: https://github.com/jmarolf/generator-start/commit/d0db05af009b29406caed7bde007d472fffc8c2f
This should allow project references to find the dependent dlls as they will be laid down next to them
Thanks, I'll try that.
@jmarolf ok, you're right, that works in your branch....now I just need to figure out how to make it work on my stuff....
@jmarolf and now I have it working in my code. Of course, I'm getting an error with the gen'd code, but that's my problem :)
Or....it doesn't work again :(. This is frustrating.
Yeah, now it's not working again. I need to walk away from this. Way too annoying :|
The project reference approach is the first thing everyone tries and is the least-tested scenario. I would go so far as to say its unsupported but @jaredpar and @chsienki have placed it in the cookbook :) There are a lot of moving pieces to making ana analyzer/generator work as a project reference and it is trivially easy to make it fall off a cliff :(
@jmarolf would you say it's better just to test the generator from a NuGet package reference? I've done that as well with other source generators I've written, and in this case, I'm perfectly fine just skipping the idea of referencing a project in a test project and using a local NuGet package reference instead.
If you are shipping a nuget package at the end of the day then I would recommend doing that.
Well, I finally gave up on the IntegrationTests
project. I just couldn't get it to work. But I created a project to test the NuGet package, and that's finally working as expected.
For whatever reason, I can't get the source generator to run in
WebAssembly.IntegrationTests
. Here's the error message I get:Here's the specific exception details:
For what it's worth, here's the
FusionLog
property value of the exception:Note that all the tests in
WebAssembly.Tests
run just fine.I'm referencing
0.9.0-preview
ofWebAssembly
on purpose, as that was the last version that targeted .NET Standard 2.0. That package switched to just targetingnetcoreapp3.1
for1.0.0
. I'm not sure if that is part of the reason - that is, if there's something in0.9.0-preview
that's causing the issue.