Skip to content

Commit 6852a7d

Browse files
authored
fix(generator): use AssemblyInformationalVersion in GeneratedCode attribute (#113)
* fix(generator): handle missing AssemblyInformationalVersion gracefully - Fallback to `AssemblyName.Version` when `AssemblyInformationalVersionAttribute` is unavailable. - Default to "unknown" if both values are missing. * fix(tests): update regex pattern in `GeneratedCodeAttributeRegex` - Enhanced regex to match version strings with a "+" suffix, e.g., `1.2.3+buildinfo`. - Adjusted formatting for better readability and maintenance. * feat(build): add support for custom versioning via `VERSION` variable - Introduced `VERSION` variable in `taskfile.yaml` for custom build versioning. - Updated `build`, `pack`, and `publish` tasks to include `/p:Version` when `VERSION` is defined. - Enforced `VERSION` requirement for `publish` and `pack-local` tasks. * fix(generator): simplify fallback logic for AssemblyInformationalVersion - Removed fallback to `AssemblyName.Version` when `AssemblyInformationalVersion` is unavailable. - Simplified assignment logic to default directly to "unknown". * refactor(taskfile): rename `pack-local` task to `publish-local` - Updated task name for clarity and consistency with its purpose. - No changes to functionality or dependencies. * fix(taskfile): include version in `publish-local` log output - Updated `echo` command to display the `VERSION` being published. - Enhances logging clarity during local NuGet publishing. * fix(workflows): update workflow templates to use latest version - Updated `publish-preview.yml` and `publish-release.yml` to reference `main` instead of `v8.0`. - Adjusted `release` event trigger syntax in `publish-release.yml` for consistency. - Ensures workflows use the latest updates from the shared templates. * fix(taskfile): include version in `publish` log output - Updated `echo` command to display the `VERSION` being published. - Improves logging clarity during NuGet package publishing. * fix(taskfile): remove quotes around `VERSION` in `build` and `pack` commands - Corrected `/p:Version` parameter to avoid quotes for compatibility with .NET CLI. - Ensures proper handling of the `VERSION` variable during build and pack tasks. * fix(generator): clean up project file formatting and configuration - Removed redundant spaces in `PackageReference` and other tag declarations for consistency. - Disabled `IncludeSourceRevisionInInformationalVersion` to streamline generated version metadata. - Ensured proper formatting of item groups and property settings in `.csproj`. * fix(tests): enhance regex pattern in `GeneratorTestHelpers` - Updated regex to match version strings with complex suffixes (`+`, `.` or `-`). - Improves version string parsing accuracy in tests.
1 parent f8e2cae commit 6852a7d

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

src/LayeredCraft.DynamoMapper.Generators/LayeredCraft.DynamoMapper.Generators.csproj

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
2020
<PackageScribanIncludeSource>true</PackageScribanIncludeSource>
2121
<EmbedUntrackedSources>true</EmbedUntrackedSources>
22+
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
2223
</PropertyGroup>
2324

2425
<ItemGroup>
@@ -29,7 +30,7 @@
2930
</ItemGroup>
3031

3132
<ItemGroup>
32-
<PackageReference Include="Humanizer.Core" PrivateAssets="all" GeneratePathProperty="true" />
33+
<PackageReference Include="Humanizer.Core" PrivateAssets="all" GeneratePathProperty="true"/>
3334
<None
3435
Include="$(PkgHumanizer_Core)\lib\netstandard2.0\*.dll"
3536
Pack="true"
@@ -51,21 +52,21 @@
5152
<PrivateAssets>all</PrivateAssets>
5253
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5354
</PackageReference>
54-
<PackageReference Include="Microsoft.CodeAnalysis.Common" PrivateAssets="all" />
55-
<PackageReference Include="Microsoft.CSharp" PrivateAssets="all" />
56-
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
57-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
58-
<PackageReference Include="Scriban" IncludeAssets="Build" />
55+
<PackageReference Include="Microsoft.CodeAnalysis.Common" PrivateAssets="all"/>
56+
<PackageReference Include="Microsoft.CSharp" PrivateAssets="all"/>
57+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all"/>
58+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all"/>
59+
<PackageReference Include="Scriban" IncludeAssets="Build"/>
5960
</ItemGroup>
6061

6162
<ItemGroup>
62-
<Compile Remove="Templates\*.scriban" />
63-
<EmbeddedResource Include="Templates\*.scriban" />
63+
<Compile Remove="Templates\*.scriban"/>
64+
<EmbeddedResource Include="Templates\*.scriban"/>
6465
</ItemGroup>
6566

6667
<ItemGroup>
67-
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
68-
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
68+
<AdditionalFiles Include="AnalyzerReleases.Shipped.md"/>
69+
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md"/>
6970
</ItemGroup>
7071

7172
<PropertyGroup>

taskfile.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ tasks:
3939
deps: [ restore ]
4040
cmds:
4141
- echo "🔨 Building Release"
42-
- dotnet build --configuration Release --no-restore {{if .VERSION}}/p:Version="{{.VERSION}}"{{end}}
42+
- dotnet build --configuration Release --no-restore {{if .VERSION}}/p:Version={{.VERSION}}{{end}}
4343
- echo "✅ Release build complete"
4444

4545
pack:
@@ -48,7 +48,7 @@ tasks:
4848
deps: [ build ]
4949
cmds:
5050
- echo "📦 Packing Packages"
51-
- dotnet pack --configuration Release --no-build --output ./nupkg {{if .VERSION}}/p:Version="{{.VERSION}}"{{end}}
51+
- dotnet pack --configuration Release --no-build --output ./nupkg {{if .VERSION}}/p:Version={{.VERSION}}{{end}}
5252
- echo "✅ Packed"
5353

5454
publish:

test/LayeredCraft.DynamoMapper.Generators.Tests/GeneratorTestHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ internal static partial class RegexHelper
215215
{
216216
[GeneratedRegex(
217217
"""
218-
(?<=\")\d+\.\d+\.\d+\+[\w]*(?=\")
218+
(?<=\")\d+\.\d+\.\d+[\w|\+|\.|\-]*(?=\")
219219
""",
220220
RegexOptions.None,
221221
"en-US"

0 commit comments

Comments
 (0)