-
Notifications
You must be signed in to change notification settings - Fork 0
Description
C#13 has (as a preview feature) the field contextual keyword that can be used instead of generating backing fields.
This should be supported in Datacute.EmbeddedResourcePropertyGenerator
Since it is possible to implement two partial methods, and in those implementations it is possible to access other backing fields (the property's own backing field is already accessible by ref), then getting rid of those backing fields would be a breaking change.
Options:
- The
fieldkeyword could be used if theSpecifiedLanguageVersionisPreviewand a configuration setting could be used to generate backing fields if required for backwards compatibility. This has the problem that if the keyword is supported in C#14, it wouldn't get used unless the language version was stillPreview. Additionally, if the feature becomes unavailable in a future language version, the code would break, and the configuration would need to be added. - A configuration setting could be used to indicate that the
fieldkeyword should be used. This has the problem that if the preview feature changes or isn't included in future language versions, the code would break (easily fixable by removing the configuration).
Given it is a preview feature, option 2 to explicitly opt in, is a better option.
It would also be helpful to flag the generated properties as obsolete/deprecated, so that they can be removed (depending on language version) once the field keyword is no longer a preview feature. At that future time a list of unsupported language versions can be checked, and used to trigger generation of the backing fields.