Code Monkey home page Code Monkey logo

Comments (8)

NeVeSpl avatar NeVeSpl commented on June 25, 2024

I see that things escalated quickly.

Do you use by any chance custom functions/*.nt.cs files?

You can always try to debug source generator, the code of the SG is a very simple one.

Keep in mind, that VS extensions and source generator are running in the same app domain(inside VS process), they share the same dlls, if you mix the latest version of extension with not the latest version of SG, you may get exception like the second one from your post.

from ntypewriter.

jons-bakerhill avatar jons-bakerhill commented on June 25, 2024

I don't have any custom *.nt.cs files.

Do you have a link on how to debug something running inside VS like the source generator? I've done lots of debugging over the years but nothing "inside" VS like that so I'm not sure where to start.

I have 0.5.2 of the extension and 0.3.2 of the source generator. I don't have any other NTypeWriter packages or extensions installed. I did a reboot after updating the packages and extension and things got "better" in that they started attempting to generate again but I'm still getting the "Unexpected exception" error when the template renders on save via the extension and source gen still fails. I'll try one more reboot after posting this comment but unless I come back and go "yay it's fixed" you can assume that didn't help.

from ntypewriter.

NeVeSpl avatar NeVeSpl commented on June 25, 2024

You need two instances of VS,

  • one instance with loaded project that uses SG
  • second one with opened SG source code

and you simply do : Debug -> Attach to process - from the second to the first instance of VS

You can also replace SG nuget with straight forward reference to SG project the same way as it is done here :

<ProjectReference Include="..\NTypewriter.SourceGenerator\NTypewriter.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

from ntypewriter.

jons-bakerhill avatar jons-bakerhill commented on June 25, 2024

Haven't had any luck getting debugging working (yet) mostly following this https://github.com/JoanComasFdz/dotnet-how-to-debug-source-generator-vs2022 I was setting up for the attach when I noticed that the extension seemed fine after I uninstalled all the source generator nuget packages so I grabbed 1 of the 100+ projects and both the extension and the source generator appear to work with just that one so I guess I'll start binary searching the projects to see if I can figure out which one is making it blow up.

from ntypewriter.

NeVeSpl avatar NeVeSpl commented on June 25, 2024

I have suspicion that the output path of one of yours projects may be null, this line would definitely throw exception in such a case:

string fullOutputPath = Path.Combine(outputPath);

from ntypewriter.

NeVeSpl avatar NeVeSpl commented on June 25, 2024

I think that all problems mentioned here were addressed, unfortunately I am not able to updated old SG releases, but since now on, they should be completely independent from VS extension.

from ntypewriter.

jons-bakerhill avatar jons-bakerhill commented on June 25, 2024

@NeVeSpl I pulled the latest and built locally. That fixed the ArgumentNullException. Any idea when the next release might be?

I suggest adding a build failing diagnostic (instead of the current warning diagnostics) when no templates are found along the lines of "No *.nt template files were found. Please make sure there is a template present in the project and its Build Action is set to C# analyzer additional file". It doesn't make sense to me to have the source builder in a project and not be using it.

That last bit gets tricky when referencing files via "existing file links" as it jumps you to the actual file location if you left click on it, you have to right click first to be able to edit the link properties and set it as an additional file. Probably not worth adding that part to the error message as it's likely an uncommon scenario.

I have some hacked in diagnostics I might be able to create a PR for, but I'm already pushing the limits of the time I can spend on this at my employer.

Thanks for the responsiveness and quick fix!

from ntypewriter.

NeVeSpl avatar NeVeSpl commented on June 25, 2024

Nuget is already published, for small fixes I usually do not do releases.

Yeah, I am not fond of adding this failing diagnostics, I would prefer to leave it as it is. The core of NT is shared between, SG, VS extension, and Blazor app, I would prefer to keep it as end platform agnostic as possible.

from ntypewriter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.