MelGrubb / BuilderGenerator

A source-generator-based implementation of the Builder pattern
https://melgrubb.github.io/BuilderGenerator/
MIT License
38 stars 8 forks source link

v2.0.3 does not work with fresh generated library based on netstandard2.0 #13

Closed LeonhardFischl closed 2 years ago

LeonhardFischl commented 2 years ago

Hi, I´m following your project since I saw your great video module on pluralsight. Since that I`m waiting on the version 2 which applies muich easier ways to generate code. Thanks for your great work by the way.

Unfortunately it seems that the current version 2.0.3 is not completely compatible with netstandard 2.0. I have to use it because my project is still based on .Net Framework 4.8 and not yet ported to .net 3.1 neigher to .net 5 or 6.

I`m using your package in a own library which depends also on my model library which is still targeting ".Net Framework 4.8". Do I have to change the target framework to ".netstandard2.0" as well?

When I´m trying to build the project, it shows me the following error:

image

My first thought was that I have to enable nullable types in my project but this did not help neigther

The error occures in: BuilderBaseClass.cs 28

Can you check this please? Thanks a lot Greetings from Munich (Bavaria, Germany)

MelGrubb commented 2 years ago

Sorry for the late reply. I never got a notification about this. It's possible it got lost in a spam filter somewhere because I know I've been getting notifications for other repos I'm part of.

Anyway. I need to get back to this. I put things on hold because so far I've been dissatisfied with Visual Studio's support for building source generators so far. Once they're built they work just fine, but the authoring and debugging process itself is still far too painful. It's getting a little better though.

I'm hoping to have a fully working and customizable BuilderGenerator in place before my previous course goes stale enough to justify redoing things, or maybe just the last module. I'll run a quick test and see what I find though.

MelGrubb commented 2 years ago

I just created a brand new netstandard2.0 project and added builders to it. I didn't get the same error you've included above, but I did get an error that sounds more closely related to your description. Instead, I got: Feature 'nullable reference types' is not available in C# 7.3. Please use language version 8.0 or greater. That error is originating from inside a base class though, so I'd have to go see if I can rephrase the code in BuilderBaseClass to not use nullable types. I'll give it a shot.

MelGrubb commented 2 years ago

I'm going to need to test this out a bit before I create a new version, but I think that if I make the generated code so that it's unaware of nullable types then it's going to be unhappy in .Net 5+ projects. Since that's the future, that's what I'm targeting now.

LeonhardFischl commented 2 years ago

Thanks a lot for your respond.

Meanwhile I forked the project and tried sth. by myself but without a result I´m fine with. My first idea was to just remove the nullable reference but it did not work. The second thought was to use an attribute to configure the "nullable types". Do you think that could work also for .Net 5+ projects?

LeonhardFischl commented 2 years ago

Hi, do you have any update for me? Any changes on the way to .net 6.x?

MelGrubb commented 2 years ago

I am finishing up the last module of a new Pluralsight course this week and next. After that, I'll be free to get back to the generator and I hope to have some blog content about that when I'm done as well.

MelGrubb commented 2 years ago

I wanted to let you know I'm back on this, and I can see the same error as you now, down to the line number, so that's a good start.