Nullable properties in ITenantInfo #532
ChristophHornung
started this conversation in
Ideas
Replies: 1 comment
-
Yes I agree with you in practice. The goal with nullable originally was to preserve existing behavior and not really to "improve" things with the feature. This is definitely an area for the next breaking release I'd like to clarify. Will probably remove Connection string alltogether. As I update samples to .NET 6 I expect to see a lot of the issues you mentioned. Thank you for your input and I'm glad you find the library useful. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
first of all thanks for this great lib, it really helped to quickly build a multi tenant app.
I recently update to the 6.6 version (from 6.5) and wondered about the nullable-annotations surrounding ITenantInfo. All properties of ITeantInfo and TenantInfo are now nullable-annotated.
This results in a few headaches in my nullable-enabled code. First of all every call to e.g.
ITenantInfo.Id
will now be marked nullable when all of my code relied onId
being present. This results in a lot of compiler warnings.Now I already use my own implementation of
ITenantInfo
so I could replace all usages ofITenantInfo
in my code with my own class. But in order for it to properly be non-nullable I had to implicitly implement the interface alongside my own non-nullable properties. I.e.:This is quite some effort to get rid of all nullability warnings and avoid lots of
!
operators in code.The way I read the library's code it seems it is always assumed that the
Id
andIdentifier
properties are notnull
. Additionally there seems no need to have a setter on theITenantInfo
' s properties in the first place. As long as the used store can handle the concrete implementation there seems no use for it.So a better approach might be to change
ITenantInfo
into:This would allow anyone to use the interface and rely on at least
Id
andIdentifier
to always be non-null and avoid nullability-warnings and additionally to implement the interface in a concrete class that has non-nullable properties (e.g. forConnectionString
).Or did I miss something that makes this change not viable?
Beta Was this translation helpful? Give feedback.
All reactions