-
Notifications
You must be signed in to change notification settings - Fork 85
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
Source generators implementation v1.x.0 #37
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It fails to restore until you build the first project, and it's fraught with caching issues, e.g. NuGet/Home#6579
So that it works in lower versions of the SDK e.g. see dotnet/roslyn#54710 (comment)
- Expand the Converters type - Add a "Defaults" assembly attribute for easier configuration of the defaults - Allow not using _any_ converters - Rename JsonConverters to Converters (as may want to add others, e.g. EF Core converters etc)
Refactor the source gen helper as we are getting more and more resources
- Fix issues in numeric IDs - Support convertTo
Updated to net462 to support long file paths
andrewlock
force-pushed
the
source-generator
branch
from
August 21, 2021 20:24
e887338
to
f02d77d
Compare
andrewlock
force-pushed
the
source-generator
branch
from
August 30, 2021 19:15
7e92044
to
c713847
Compare
This should provide performance improvements, though it requires the .NET 6 SDK/VS 2022
…a project if necessary
Can be used when you run into InternalsVisibleTo issues Add tests for excluding the emitted attributes from your compilation, and for using the Attributes package instead
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initial conversion to source generators.
Changes in version 1.x
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;
.StronglyTypedIds
have changed: there is no longer agenerateJsonConverter
property. Instead, this is infered based on theStronglyTypedIdConverters
flags provided.String
backing typed ID will throw if you call the constructor with anull
valueNew Features
ValueConverter
and DapperTypeHandler
, as described in my blog posts. These are optional flags on theconverters
property.IEquatable<T>
andIComparable<T>
currently) optional. This is to potentially support additional interfaces in future versions.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.[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
String
backing type, handling issues such as #32.