Skip to content
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

Would love to see this converted to use Nullable Reference Types #4

Open
StevenTCramer opened this issue Mar 22, 2021 · 3 comments
Open

Comments

@StevenTCramer
Copy link

I am using nullable reference types on a Pulumi IaC project where I use the builder pattern. But find it difficult to get dotnet to figure out when items are not null.

The Builder Pattern is a delayed constructor.
The things it is supposed to build will be null until the Build() method has been executed.
But after Build they won't be null.

I try to help by using MemberNotNull attributes but that seems to just kick the can down the road only level.

@Arnab-Developer
Copy link
Contributor

If we implement #8 then it will be easy to use nullable types.

@wgaffa
Copy link
Contributor

wgaffa commented Jun 17, 2021

Adding the <Nullable>enable</Nullable> is what is needed but there is a lot of warnings of course.
Those errors can be removed by giving the different instances "default" values. But I think it's not very good practice doing so.

The question is also what would a "default" value be for example for a Customer object. And if we create two default Customer objects, are they considered equal or not because the have the same values or are they only equal if they have the same reference.

But if someone want's to play with nullable references you can just add <Nullable>enable</Nullable> in BuilderTestSample.csproj under the first <PropertyGroup> and build it.

Not sure this is worth it adding in the main repository.

@Arnab-Developer
Copy link
Contributor

You can check my attempt of this kata.

https://github.com/Arnab-Developer/BuilderTestSample/tree/Arnab-Developer/16-06-2021

I have used null reference type in that.

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

No branches or pull requests

3 participants