Skip to content

Commit 681feda

Browse files
committed
first commit
1 parent 4f26e1b commit 681feda

22 files changed

+1499
-1
lines changed

.editorconfig

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# EditorConfig: https://EditorConfig.org
2+
3+
root = true
4+
5+
# All Files
6+
[*]
7+
charset = utf-8
8+
indent_style = space
9+
indent_size = 4
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
# XML Configuration Files
14+
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct,refactorlog,runsettings}]
15+
indent_size = 2
16+
17+
# JSON Files
18+
[*.{json,json5,webmanifest}]
19+
indent_size = 2
20+
21+
# Project Files
22+
[*.{csproj,sqlproj}]
23+
indent_size = 2
24+
25+
# YAML Files
26+
[*.{yml,yaml}]
27+
indent_size = 2
28+
29+
# Markdown Files
30+
[*.md]
31+
trim_trailing_whitespace = false
32+
33+
# Web Files
34+
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,pcss,svg,vue}]
35+
indent_size = 2
36+
37+
# Batch Files
38+
[*.{cmd,bat}]
39+
end_of_line = crlf
40+
41+
# Bash Files
42+
[*.sh]
43+
end_of_line = lf
44+
45+
[*.{cs,vb}]
46+
dotnet_sort_system_directives_first = true
47+
dotnet_separate_import_directive_groups = true
48+
dotnet_style_namespace_match_folder = true
49+
50+
[*.cs]
51+
csharp_using_directive_placement = outside_namespace
52+
csharp_style_namespace_declarations = file_scoped:warning

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: nuget
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "11:00"
8+
open-pull-requests-limit: 10

.github/workflows/dotnet.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Build Project
2+
3+
env:
4+
DOTNET_NOLOGO: true
5+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
6+
BUILD_PATH: '${{github.workspace}}/artifacts'
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
- develop
13+
tags:
14+
- 'v*'
15+
pull_request:
16+
branches:
17+
- main
18+
- develop
19+
20+
jobs:
21+
build:
22+
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Install .NET Core
32+
uses: actions/setup-dotnet@v3
33+
with:
34+
dotnet-version: 7.0.x
35+
36+
- name: Calculate Version
37+
run: |
38+
dotnet tool update -g minver-cli
39+
echo "BUILD_VERSION=$(minver -v e -t v)" >> $GITHUB_ENV
40+
41+
- name: Restore Dependencies
42+
run: dotnet restore
43+
44+
- name: Build Solution
45+
run: 'dotnet build --no-restore --configuration Release -p:Version="${{env.BUILD_VERSION}}" -p:InformationalVersion="${{env.BUILD_VERSION}}+${{github.sha}}"'
46+
47+
- name: Run Test
48+
run: dotnet test --no-build --configuration Release --collect:"XPlat Code Coverage" --settings coverlet.runsettings
49+
50+
- name: Generate Coverage
51+
uses: danielpalme/[email protected]
52+
with:
53+
reports: '${{github.workspace}}/test/*/TestResults/*/coverage.info'
54+
targetdir: ${{env.BUILD_PATH}}
55+
reporttypes: lcov
56+
57+
- name: Report Coverage
58+
if: success()
59+
uses: coverallsapp/github-action@v2
60+
with:
61+
file: artifacts/lcov.info
62+
format: lcov
63+
64+
- name: Create Packages
65+
if: success() && github.event_name != 'pull_request'
66+
run: dotnet pack --configuration Release --include-symbols --include-source --no-build --no-restore --output "${{env.BUILD_PATH}}"
67+
68+
- name: Upload Packages
69+
if: success() && github.event_name != 'pull_request'
70+
uses: actions/upload-artifact@v3
71+
with:
72+
name: packages
73+
path: '${{env.BUILD_PATH}}'
74+
75+
deploy:
76+
runs-on: ubuntu-latest
77+
needs: build
78+
if: success() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
79+
80+
steps:
81+
- name: Download Artifact
82+
uses: actions/download-artifact@v3
83+
with:
84+
name: packages
85+
86+
- name: Publish Packages GitHub
87+
run: |
88+
for package in $(find -name "*.nupkg"); do
89+
echo "${0##*/}": Pushing $package...
90+
dotnet nuget push $package --source https://nuget.pkg.github.com/loresoft/index.json --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
91+
done
92+
93+
- name: Publish Packages feedz
94+
run: |
95+
for package in $(find -name "*.nupkg"); do
96+
echo "${0##*/}": Pushing $package...
97+
dotnet nuget push $package --source https://f.feedz.io/loresoft/open/nuget/index.json --api-key ${{ secrets.FEEDDZ_KEY }} --skip-duplicate
98+
done
99+
100+
- name: Publish Packages Nuget
101+
if: startsWith(github.ref, 'refs/tags/v')
102+
run: |
103+
for package in $(find -name "*.nupkg"); do
104+
echo "${0##*/}": Pushing $package...
105+
dotnet nuget push $package --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }} --skip-duplicate
106+
done
107+

AssemblyMetadata.Generators.sln

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyMetadata.Generators", "src\AssemblyMetadata.Generators\AssemblyMetadata.Generators.csproj", "{57C67863-03B3-4E43-8881-7B19A5657FE0}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{1BA030F4-6549-4F95-ACEA-80E992C519BD}"
9+
ProjectSection(SolutionItems) = preProject
10+
src\Directory.Build.props = src\Directory.Build.props
11+
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
12+
README.md = README.md
13+
EndProjectSection
14+
EndProject
15+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssemblyMetadata.Generators.Tests", "test\AssemblyMetadata.Generators.Tests\AssemblyMetadata.Generators.Tests.csproj", "{DF58389E-0A0F-49EB-8FF0-943E85AF3FD0}"
16+
EndProject
17+
Global
18+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
19+
Debug|Any CPU = Debug|Any CPU
20+
Release|Any CPU = Release|Any CPU
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{57C67863-03B3-4E43-8881-7B19A5657FE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{57C67863-03B3-4E43-8881-7B19A5657FE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{57C67863-03B3-4E43-8881-7B19A5657FE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{57C67863-03B3-4E43-8881-7B19A5657FE0}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{DF58389E-0A0F-49EB-8FF0-943E85AF3FD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{DF58389E-0A0F-49EB-8FF0-943E85AF3FD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{DF58389E-0A0F-49EB-8FF0-943E85AF3FD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{DF58389E-0A0F-49EB-8FF0-943E85AF3FD0}.Release|Any CPU.Build.0 = Release|Any CPU
31+
EndGlobalSection
32+
GlobalSection(SolutionProperties) = preSolution
33+
HideSolutionNode = FALSE
34+
EndGlobalSection
35+
GlobalSection(ExtensibilityGlobals) = postSolution
36+
SolutionGuid = {17C9AE5B-2227-4FE0-868F-4FDC16F6DD8F}
37+
EndGlobalSection
38+
EndGlobal

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
11
# AssemblyMetadata.Generators
2-
Source generator for project and assembly information as constants in the global AssemblyMetadata class
2+
3+
Source generator to expose assembly attributes as string constants.
4+
5+
[![Build status](https://github.com/loresoft/AssemblyMetadata.Generators/workflows/Build/badge.svg)](https://github.com/loresoft/AssemblyMetadata.Generators/actions)
6+
7+
[![NuGet Version](https://img.shields.io/nuget/v/AssemblyMetadata.Generators.svg?style=flat-square)](https://www.nuget.org/packages/AssemblyMetadata.Generators/)
8+
9+
### Usage
10+
11+
#### Add package
12+
13+
Add the nuget package project to your projects.
14+
15+
`dotnet add package AssemblyMetadata.Generators`
16+
17+
### Generated
18+
19+
This source generator creates an internal partial class called `ThisAssembly` with all the assembly level attributes converted to string constants
20+
21+
```c#
22+
internal static partial class ThisAssembly
23+
{
24+
public const string TargetFramework = ".NETCoreApp,Version=v7.0";
25+
public const string Company = "LoreSoft";
26+
public const string Configuration = "Debug";
27+
public const string Copyright = "Copyright © 2023 LoreSoft";
28+
public const string Description = "Source generator to expose assembly attributes as string constants";
29+
public const string FileVersion = "1.0.0.0";
30+
public const string InformationalVersion = "1.0.0";
31+
public const string Product = "AssemblyMetadata.Generators.Tests";
32+
public const string Title = "AssemblyMetadata.Generators.Tests";
33+
public const string Version = "1.0.0.0";
34+
public const string RepositoryUrl = "https://github.com/loresoft/AssemblyMetadata.Generators";
35+
public const string NeutralResourcesLanguage = "en-US";
36+
}
37+
```

coverlet.runsettings

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<RunSettings>
3+
<DataCollectionRunSettings>
4+
<DataCollectors>
5+
<DataCollector friendlyName="XPlat code coverage">
6+
<Configuration>
7+
<Format>lcov</Format>
8+
<ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute,TestSDKAutoGeneratedCode</ExcludeByAttribute>
9+
<SkipAutoProps>true</SkipAutoProps>
10+
</Configuration>
11+
</DataCollector>
12+
</DataCollectors>
13+
</DataCollectionRunSettings>
14+
</RunSettings>

logo.png

4.89 KB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace AssemblyMetadata.Generators;
2+
3+
public class AssemblyConstant : IEquatable<AssemblyConstant>
4+
{
5+
public AssemblyConstant(string name, string value)
6+
{
7+
Name = name;
8+
Value = value;
9+
}
10+
11+
public string Name { get; }
12+
13+
public string Value { get; }
14+
15+
public bool Equals(AssemblyConstant other)
16+
{
17+
if (ReferenceEquals(null, other))
18+
return false;
19+
20+
if (ReferenceEquals(this, other))
21+
return true;
22+
23+
return Name == other.Name
24+
&& Value == other.Value;
25+
}
26+
27+
public override bool Equals(object value) => value is AssemblyConstant assemblyContant && Equals(assemblyContant);
28+
29+
public override int GetHashCode() => HashCode.Combine(Name, Value);
30+
31+
public static bool operator ==(AssemblyConstant left, AssemblyConstant right) => Equals(left, right);
32+
33+
public static bool operator !=(AssemblyConstant left, AssemblyConstant right) => !Equals(left, right);
34+
35+
public override string ToString() => $"Name: {Name}; Value: {Value}";
36+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<ImplicitUsings>true</ImplicitUsings>
6+
<IsRoslynComponent>true</IsRoslynComponent>
7+
<DevelopmentDependency>true</DevelopmentDependency>
8+
<AnalyzerLanguage>cs</AnalyzerLanguage>
9+
<AnalyzerRoslynVersion>4.3</AnalyzerRoslynVersion>
10+
<LangVersion>latest</LangVersion>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" PrivateAssets="all" />
15+
</ItemGroup>
16+
17+
</Project>

0 commit comments

Comments
 (0)