Fixes
- Fix bug in System.Text.Json converters that could cause errors when used with source generators
Breaking Changes:
- This release contains a fundamental change in how you define your IDs
- For details see the related issue, the PR, or the README
- The "options" enums
StronglyTypedIdBackingType
,StronglyTypedIdConverter
, andStronglyTypedIdImplementations
have been removed. - Instead, you simply choose one of 4 different built-in templates, or use a custom template.
Features
- Adds
[GeneratedCode]
attribute to generated IDs (Fixes #57) - Add support for parsing
SCOPE_IDENTITY()
and@@IDENTITY
in MSSQL withDapperTypeHandler
(Fixes #118) - Fix exception being thrown when deserializing nullable strongly-typed id backed by string (Fixes #83)
- Allow creating multiple IDs with the same name in a project (Fixes #74, thanks @jo-goro!)
Features
- Added support for Masstransit.NewId (thanks @Khitiara!) Fixes #51
- Added parameterless constructor to EF Core ValueConverts for compatibility with global conventions. Fixes #50
- Added
#pragma warning disable 1591
to generated code to avoid warning CS1591. Fixes #47
Breaking Changes:
- Removed StronglyTypedId.Attributes NuGet package.
- The attributes are no longer embed in your project by default, instead it will use the external dll. You can re-enable the embedding by setting
STRONGLY_TYPED_ID_EMBED_ATTRIBUTES
.
New Features:
- Improved approach to handling [InternalsVisibleTo] issues, by embedding the StronglyTypedId.Attributes.dll in the NuGet package directly.
New Features:
- Added support for IDs inside nested classes/records/structs (Fixes #40)
Breaking Changes:
- Converted to use .NET 6's incremental source generators. This should provide performance improvements, but it requires using the .NET 6 SDK.
Bug fixes:
- Fixed problem deserializing nullable strongly-typed IDs with Newtonsoft.Json (#36)
New Features:
- To support scenarios in which [InternalsVisibleTo] causes duplicate reference issues with the marker attributes, you can set the msbuild constant
STRONGLY_TYPED_ID_EXCLUDE_ATTRIBUTES
to exclude these from build output. You must then reference the StronglyTypedId.Attributes project as well, which contains the marker attributes. - By default, the marker attributes are decorated with the
[Conditional]
attribute, so they will not appear on your IDs. If you need these to persist, define the msbuild constantSTRONGLY_TYPED_ID_USAGES
.
Bug fixes
- Adds auto-generated attributes and enums as
internal
to help avoid referencing issues
Version 0.x of this library used the helper library CodeGeneration.Roslyn by AArnott, for build-time source generation. In version 1.x this approach has been completely replaced in favour of source generators, as these are explicitly supported in .NET 5+. As part of this change, there were a number of additional features added and breaking changes made.
Breaking Changes
StronglyTypedIds
namespace is required. In version 0.x of the library, the[StronglyTypedId]
attribute was in the global namespace. In version 1.x, the attribute is in theStronglyTypedIds
namespace, so you must addnamespace StronglyTypedIds;
.- The properties exposed by
StronglyTypedIds
have changed: there is no longer agenerateJsonConverter
property. Instead, this is infered based on theStronglyTypedIdConverters
flags provided. - The
String
backing typed ID will throw if you call the constructor with anull
value
New Features
- The attributes can now auto-generate additional converter types such as EF Core
ValueConverter
and DapperTypeHandler
, as described in my blog posts. These are optional flags on theconverters
property. - Made interface implementations (
IEquatable<T>
andIComparable<T>
currently) optional. This is to potentially support additional interfaces in future versions. - Added a
NullableString
backing type. Due to the behaviour ofstruct
s in c#, theString
backing type ID may still be null, but you can't explicitly call the constructor with a null value. In contrast, you can do this with theNullableString
backing type. - Added a
[StronglyTypedIdDefaults]
attribute to set default values for all[StronglyTypedId]
attributes in your project. This is useful if you want to customise all the attributes, for example, if you want to generate additional converters by default. You can still override all the properties of a[StronglyTypedId]
instance.
Bug Fixes
- Some converters had incorrect implementations, such as in (#26). These have been addressed in version 1.x.
- Better null handling has been added for the
String
backing type, handling issues such as #32. - The code is marked as auto generated, to avoid errors such as #CS1591 as described in #27
Features:
- Fix Package description
Features:
- Added support for .NET Core 3.1, and converted to using CodeGeneration.Roslyn.Tool instead of dotnet-codegen (thanks Bartłomiej Oryszak )
- Added support for generating System.Text.Json
JsonConverters
(thanks Bartłomiej Oryszak ) - Added support for long backing type (thanks Bartłomiej Oryszak )
Initial release