diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..19e6f77 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + DOTNET_NOLOGO: 1 + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + name: Install Current .NET SDK + - name: Restore dependencies + run: dotnet restore /p:TreatWarningsAsErrors=true + - name: Build + run: dotnet build --configuration Release --no-restore /p:TreatWarningsAsErrors=true + + nupkg: + name: Package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + name: Install Current .NET SDK + - name: Generate NuGet Packages + run: dotnet pack --configuration Release --output nupkg /p:TreatWarningsAsErrors=true + - uses: actions/upload-artifact@v4 + if: success() && github.ref == 'refs/heads/main' + with: + name: nupkg + path: nupkg/* + retention-days: 1 diff --git a/CodeStyle.sln b/CodeStyle.sln index 58ea566..736d505 100644 --- a/CodeStyle.sln +++ b/CodeStyle.sln @@ -3,6 +3,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeStyle", "CodeStyle\CodeStyle.csproj", "{F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Items", "Build Items", "{5C0E54AE-4230-4E3F-AE0B-10C8B504B486}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + Directory.Build.props = Directory.Build.props + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{92A75F6E-4785-4626-9AD3-D111C0185E23}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + changelog.md = changelog.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -11,4 +25,10 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection EndGlobal diff --git a/CodeStyle/CodeStyle.csproj b/CodeStyle/CodeStyle.csproj new file mode 100644 index 0000000..90a470b --- /dev/null +++ b/CodeStyle/CodeStyle.csproj @@ -0,0 +1,27 @@ + + + + 1.0.0 + Polyadic.CodeStyle + analyzers + Various analyzers bundled with opinionated configuration + $(NoWarn);NU5104;NU5128 + + + + + netstandard2.0 + + + + + + + + true + %(Identity) + + + diff --git a/CodeStyle/build/Default.ruleset b/CodeStyle/build/Default.ruleset new file mode 100644 index 0000000..63604f5 --- /dev/null +++ b/CodeStyle/build/Default.ruleset @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/CodeStyle/build/Disposable.ruleset b/CodeStyle/build/Disposable.ruleset new file mode 100644 index 0000000..fcdf939 --- /dev/null +++ b/CodeStyle/build/Disposable.ruleset @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CodeStyle/build/Polyadic.CodeStyle.editorconfig b/CodeStyle/build/Polyadic.CodeStyle.editorconfig new file mode 100644 index 0000000..7405d6e --- /dev/null +++ b/CodeStyle/build/Polyadic.CodeStyle.editorconfig @@ -0,0 +1,4 @@ +is_global = true + +dotnet_diagnostic.IDE0005.severity = warning # IDE0005: Using directive is unnecessary. +csharp_style_namespace_declarations = file_scoped:error diff --git a/CodeStyle/build/Polyadic.CodeStyle.props b/CodeStyle/build/Polyadic.CodeStyle.props new file mode 100644 index 0000000..3208a5d --- /dev/null +++ b/CodeStyle/build/Polyadic.CodeStyle.props @@ -0,0 +1,13 @@ + + + + $(MSBuildThisFileDirectory)Default.ruleset + $(WarningsAsErrors);nullable + true + true + + + + + + diff --git a/CodeStyle/build/StyleCop.ruleset b/CodeStyle/build/StyleCop.ruleset new file mode 100644 index 0000000..ee220b4 --- /dev/null +++ b/CodeStyle/build/StyleCop.ruleset @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CodeStyle/build/stylecop.json b/CodeStyle/build/stylecop.json new file mode 100644 index 0000000..04cc7a0 --- /dev/null +++ b/CodeStyle/build/stylecop.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "orderingRules": { + "usingDirectivesPlacement": "outsideNamespace" + } + } +} diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..e9522b5 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,18 @@ + + + + Polyadic + MIT OR Apache-2.0 + https://github.com/polyadic/code-style + © Polyadic. All rights reserved. + + + 5.0 + + + enable + + + $(MSBuildThisFileDirectory)artifacts + + diff --git a/README.md b/README.md index 31a72d1..75510be 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Shared Code Style for all Polyadic/Funcky projects. The rules are configured with the expectation that you build with `/p:TreatWarningsAsErrors=true` on CI. +## Credits +The `Polyadic.CodeStyle` package started as a direct copy of +[`Messerli.CodeStyle`](https://github.com/messerli-informatik-ag/code-style), licensed under either Apache 2.0 or MIT. + ## License Licensed under either of diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..825c32f --- /dev/null +++ b/changelog.md @@ -0,0 +1 @@ +# Changelog diff --git a/global.json b/global.json new file mode 100644 index 0000000..71cf3fc --- /dev/null +++ b/global.json @@ -0,0 +1,9 @@ +{ + "sdk": { + "version": "9.0.100", + "rollForward": "feature" + }, + "msbuild-sdks": { + "Microsoft.Build.NoTargets": "3.7.56" + } +}