Skip to content

Commit b44ab92

Browse files
authored
Merge pull request #37 from andrewlock/source-generator
Source generators implementation v1.0.0-beta
2 parents 4b533c1 + 2de3c01 commit b44ab92

File tree

1,699 files changed

+151523
-6267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,699 files changed

+151523
-6267
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Set default behavior to automatically normalize line endings.
33
###############################################################################
44
* text=auto
5+
*.sh eol=lf
56

67
###############################################################################
78
# Set default behavior for command prompt diff.

.github/workflows/BuildAndPack.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# ------------------------------------------------------------------------------
2+
# <auto-generated>
3+
#
4+
# This code was generated.
5+
#
6+
# - To turn off auto-generation set:
7+
#
8+
# [GitHubActions (AutoGenerate = false)]
9+
#
10+
# - To trigger manual generation invoke:
11+
#
12+
# nuke --generate-configuration GitHubActions_BuildAndPack --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: BuildAndPack
18+
19+
on:
20+
push:
21+
branches:
22+
- master
23+
- main
24+
tags:
25+
- '*'
26+
pull_request:
27+
branches:
28+
- '*'
29+
30+
jobs:
31+
ubuntu-latest:
32+
name: ubuntu-latest
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v1
36+
- uses: actions/setup-dotnet@v1
37+
with:
38+
dotnet-version: '6.0.x'
39+
include-prerelease: true
40+
- uses: actions/setup-dotnet@v1
41+
with:
42+
dotnet-version: '5.0.x'
43+
- uses: actions/setup-dotnet@v1
44+
with:
45+
dotnet-version: '3.1.x'
46+
- uses: actions/setup-dotnet@v1
47+
with:
48+
dotnet-version: '2.1.x'
49+
- name: Cache .nuke/temp, ~/.nuget/packages
50+
uses: actions/cache@v2
51+
with:
52+
path: |
53+
.nuke/temp
54+
~/.nuget/packages
55+
!~/.nuget/packages/stronglytypeid
56+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
57+
- name: Run './build.cmd Clean Test TestPackages PushToNuGet'
58+
run: ./build.cmd Clean Test TestPackages PushToNuGet
59+
env:
60+
GithubToken: ${{ secrets.GITHUB_TOKEN }}
61+
NuGetToken: ${{ secrets.NUGET_TOKEN }}
62+
MSBuildEnableWorkloadResolver: false
63+
- uses: actions/upload-artifact@v1
64+
with:
65+
name: artifacts
66+
path: artifacts
67+
windows-latest:
68+
name: windows-latest
69+
runs-on: windows-latest
70+
steps:
71+
- uses: actions/checkout@v1
72+
- uses: actions/setup-dotnet@v1
73+
with:
74+
dotnet-version: '6.0.x'
75+
include-prerelease: true
76+
- uses: actions/setup-dotnet@v1
77+
with:
78+
dotnet-version: '5.0.x'
79+
- uses: actions/setup-dotnet@v1
80+
with:
81+
dotnet-version: '3.1.x'
82+
- uses: actions/setup-dotnet@v1
83+
with:
84+
dotnet-version: '2.1.x'
85+
- name: Cache .nuke/temp, ~/.nuget/packages
86+
uses: actions/cache@v2
87+
with:
88+
path: |
89+
.nuke/temp
90+
~/.nuget/packages
91+
!~/.nuget/packages/stronglytypeid
92+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
93+
- name: Run './build.cmd Clean Test TestPackages PushToNuGet'
94+
run: ./build.cmd Clean Test TestPackages PushToNuGet
95+
env:
96+
GithubToken: ${{ secrets.GITHUB_TOKEN }}
97+
NuGetToken: ${{ secrets.NUGET_TOKEN }}
98+
MSBuildEnableWorkloadResolver: false
99+
- uses: actions/upload-artifact@v1
100+
with:
101+
name: artifacts
102+
path: artifacts
103+
macOS-latest:
104+
name: macOS-latest
105+
runs-on: macOS-latest
106+
steps:
107+
- uses: actions/checkout@v1
108+
- uses: actions/setup-dotnet@v1
109+
with:
110+
dotnet-version: '6.0.x'
111+
include-prerelease: true
112+
- uses: actions/setup-dotnet@v1
113+
with:
114+
dotnet-version: '5.0.x'
115+
- uses: actions/setup-dotnet@v1
116+
with:
117+
dotnet-version: '3.1.x'
118+
- uses: actions/setup-dotnet@v1
119+
with:
120+
dotnet-version: '2.1.x'
121+
- name: Cache .nuke/temp, ~/.nuget/packages
122+
uses: actions/cache@v2
123+
with:
124+
path: |
125+
.nuke/temp
126+
~/.nuget/packages
127+
!~/.nuget/packages/stronglytypeid
128+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
129+
- name: Run './build.cmd Clean Test TestPackages PushToNuGet'
130+
run: ./build.cmd Clean Test TestPackages PushToNuGet
131+
env:
132+
GithubToken: ${{ secrets.GITHUB_TOKEN }}
133+
NuGetToken: ${{ secrets.NUGET_TOKEN }}
134+
MSBuildEnableWorkloadResolver: false
135+
- uses: actions/upload-artifact@v1
136+
with:
137+
name: artifacts
138+
path: artifacts

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
[Rr]eleases/
1919
[Xx]64/
2020
[Xx]86/
21-
[Bb]uild/
2221
bld/
2322
[Bb]in/
2423
[Oo]bj/
@@ -246,5 +245,3 @@ ModelManifest.xml
246245
.fake/
247246
tools/*
248247
!tools/packages.config
249-
250-
! src/StronglyTypedId.Generator/build/

.nuke/build.schema.json

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Build Schema",
4+
"$ref": "#/definitions/build",
5+
"definitions": {
6+
"build": {
7+
"type": "object",
8+
"properties": {
9+
"Configuration": {
10+
"type": "string",
11+
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
12+
"enum": [
13+
"Debug",
14+
"Release"
15+
]
16+
},
17+
"Continue": {
18+
"type": "boolean",
19+
"description": "Indicates to continue a previously failed build attempt"
20+
},
21+
"GithubToken": {
22+
"type": "string"
23+
},
24+
"Help": {
25+
"type": "boolean",
26+
"description": "Shows the help text for this build assembly"
27+
},
28+
"Host": {
29+
"type": "string",
30+
"description": "Host for execution. Default is 'automatic'",
31+
"enum": [
32+
"AppVeyor",
33+
"AzurePipelines",
34+
"Bamboo",
35+
"Bitrise",
36+
"GitHubActions",
37+
"GitLab",
38+
"Jenkins",
39+
"Rider",
40+
"SpaceAutomation",
41+
"TeamCity",
42+
"Terminal",
43+
"TravisCI",
44+
"VisualStudio",
45+
"VSCode"
46+
]
47+
},
48+
"NoLogo": {
49+
"type": "boolean",
50+
"description": "Disables displaying the NUKE logo"
51+
},
52+
"NuGetToken": {
53+
"type": "string"
54+
},
55+
"PackagesDirectory": {
56+
"type": "string"
57+
},
58+
"Partition": {
59+
"type": "string",
60+
"description": "Partition to use on CI"
61+
},
62+
"Plan": {
63+
"type": "boolean",
64+
"description": "Shows the execution plan (HTML)"
65+
},
66+
"Profile": {
67+
"type": "array",
68+
"description": "Defines the profiles to load",
69+
"items": {
70+
"type": "string"
71+
}
72+
},
73+
"Root": {
74+
"type": "string",
75+
"description": "Root directory during build execution"
76+
},
77+
"Skip": {
78+
"type": "array",
79+
"description": "List of targets to be skipped. Empty list skips all dependencies",
80+
"items": {
81+
"type": "string",
82+
"enum": [
83+
"Clean",
84+
"Compile",
85+
"Pack",
86+
"PushToNuGet",
87+
"Restore",
88+
"Test",
89+
"TestPackages"
90+
]
91+
}
92+
},
93+
"Solution": {
94+
"type": "string",
95+
"description": "Path to a solution file that is automatically loaded"
96+
},
97+
"Target": {
98+
"type": "array",
99+
"description": "List of targets to be invoked. Default is '{default_target}'",
100+
"items": {
101+
"type": "string",
102+
"enum": [
103+
"Clean",
104+
"Compile",
105+
"Pack",
106+
"PushToNuGet",
107+
"Restore",
108+
"Test",
109+
"TestPackages"
110+
]
111+
}
112+
},
113+
"Verbosity": {
114+
"type": "string",
115+
"description": "Logging verbosity during build execution. Default is 'Normal'",
116+
"enum": [
117+
"Minimal",
118+
"Normal",
119+
"Quiet",
120+
"Verbose"
121+
]
122+
}
123+
}
124+
}
125+
}
126+
}

.nuke/parameters.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./build.schema.json",
3+
"Solution": "StronglyTypedId.sln"
4+
}

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
# Changelog
22

3+
## [v1.0.0-beta03]
4+
5+
Breaking Changes:
6+
7+
* Converted to use .NET 6's incremental source generators. This should provide performance improvements, but it requires using the .NET 6 SDK.
8+
9+
Bug fixes:
10+
11+
* Fixed problem deserializing nullable strongly-typed IDs with Newtonsoft.Json (https://github.com/andrewlock/StronglyTypedId/issues/36)
12+
13+
New Features:
14+
15+
* 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.
16+
* 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 constant `STRONGLY_TYPED_ID_USAGES`.
17+
18+
## [v1.0.0-beta02]
19+
20+
Bug fixes
21+
22+
* Adds auto-generated attributes and enums as `internal` to help avoid referencing issues
23+
24+
## [v1.0.0-beta01]
25+
26+
Version 0.x of this library used the helper library [CodeGeneration.Roslyn](https://github.com/AArnott/CodeGeneration.Roslyn) by [AArnott](https://github.com/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.
27+
28+
Breaking Changes
29+
30+
* `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 the `StronglyTypedIds` namespace, so you must add `namespace StronglyTypedIds;`.
31+
* The properties exposed by `StronglyTypedIds` have changed: there is no longer a `generateJsonConverter` property. Instead, this is infered based on the `StronglyTypedIdConverters` flags provided.
32+
* The `String` backing typed ID will throw if you call the constructor with a `null` value
33+
34+
New Features
35+
36+
* The attributes can now auto-generate additional converter types such as EF Core `ValueConverter` and Dapper `TypeHandler`, as described in [my blog posts](https://andrewlock.net/series/using-strongly-typed-entity-ids-to-avoid-primitive-obsession/). These are optional flags on the `converters` property.
37+
* Made interface implementations (`IEquatable<T>` and `IComparable<T>` currently) optional. This is to potentially support additional interfaces in future versions.
38+
* Added a `NullableString` backing type. Due to the behaviour of `struct`s in c#, the `String` 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 the `NullableString` backing type.
39+
* 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.
40+
41+
Bug Fixes
42+
43+
* Some converters had incorrect implementations, such as in ([#26](https://github.com/andrewlock/StronglyTypedId/issues/24)). These have been addressed in version 1.x.
44+
* Better null handling has been added for the `String` backing type, handling issues such as [#32](https://github.com/andrewlock/StronglyTypedId/issues/32).
45+
* The code is marked as auto generated, to avoid errors such as #CS1591 as described in [#27](https://github.com/andrewlock/StronglyTypedId/issues/27)
46+
347
## [v0.2.1]
448

549
Features:

Directory.Build.props

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,38 @@
88
<Copyright>Copyright © AndrewLock</Copyright>
99
<NeutralLanguage>en-GB</NeutralLanguage>
1010
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
11-
<PackageLicenseUrl>https://raw.githubusercontent.com/andrewlock/StronglyTypedId/master/LICENSE</PackageLicenseUrl>
11+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12+
<PackageIcon>logo.png</PackageIcon>
1213
<PackageProjectUrl>https://github.com/andrewlock/StronglyTypedId</PackageProjectUrl>
13-
<PackageIconUrl>https://raw.githubusercontent.com/andrewlock/StronglyTypedId/master/logo.png</PackageIconUrl>
1414
<PackageTags>stronglytypedid attribute generator generation codegen codegenerator codegeneration netescapades</PackageTags>
1515
<RepositoryUrl>https://github.com/andrewlock/StronglyTypedId</RepositoryUrl>
1616
<RepositoryType>git</RepositoryType>
17+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
1718
</PropertyGroup>
1819

1920
<PropertyGroup>
2021
<DebugType>embedded</DebugType>
2122
<NoPackageAnalysis>true</NoPackageAnalysis>
22-
<LangVersion>7.3</LangVersion>
23-
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
24-
<PackageOutputPath>$(SolutionDir)/artifacts</PackageOutputPath>
25-
<CodeGenerationRoslynPackagesVersion>0.7.63</CodeGenerationRoslynPackagesVersion>
23+
<LangVersion>latest</LangVersion>
24+
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
25+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
26+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
27+
<PackageOutputPath>$(MSBuildThisFileDirectory)\artifacts</PackageOutputPath>
2628
</PropertyGroup>
2729

30+
<PropertyGroup>
31+
<PackageReadmeFile>README.md</PackageReadmeFile>
32+
</PropertyGroup>
33+
34+
<ItemGroup>
35+
<None Include="$(MSBuildThisFileDirectory)\logo.png" Pack="true" PackagePath="\"/>
36+
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="\"/>
37+
</ItemGroup>
38+
39+
<ItemGroup>
40+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
41+
</ItemGroup>
42+
2843
<Import Project="releasenotes.props" />
2944

3045
</Project>

NuGet.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)