Skip to content

Commit 0544365

Browse files
authored
Merge pull request #1 from polyadic/copy-code-style
2 parents ef97132 + 24ce725 commit 0544365

13 files changed

+399
-0
lines changed

.github/workflows/ci.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
DOTNET_NOLOGO: 1
11+
12+
jobs:
13+
build:
14+
name: Build
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-dotnet@v4
19+
name: Install Current .NET SDK
20+
- name: Restore dependencies
21+
run: dotnet restore /p:TreatWarningsAsErrors=true
22+
- name: Build
23+
run: dotnet build --configuration Release --no-restore /p:TreatWarningsAsErrors=true
24+
25+
nupkg:
26+
name: Package
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- uses: actions/setup-dotnet@v4
31+
name: Install Current .NET SDK
32+
- name: Generate NuGet Packages
33+
run: dotnet pack --configuration Release --output nupkg /p:TreatWarningsAsErrors=true
34+
- uses: actions/upload-artifact@v4
35+
if: success() && github.ref == 'refs/heads/main'
36+
with:
37+
name: nupkg
38+
path: nupkg/*
39+
retention-days: 1

CodeStyle.sln

+20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeStyle", "CodeStyle\CodeStyle.csproj", "{F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Items", "Build Items", "{5C0E54AE-4230-4E3F-AE0B-10C8B504B486}"
9+
ProjectSection(SolutionItems) = preProject
10+
global.json = global.json
11+
Directory.Build.props = Directory.Build.props
12+
EndProjectSection
13+
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{92A75F6E-4785-4626-9AD3-D111C0185E23}"
15+
ProjectSection(SolutionItems) = preProject
16+
README.md = README.md
17+
changelog.md = changelog.md
18+
EndProjectSection
19+
EndProject
620
Global
721
GlobalSection(SolutionConfigurationPlatforms) = preSolution
822
Debug|Any CPU = Debug|Any CPU
@@ -11,4 +25,10 @@ Global
1125
GlobalSection(SolutionProperties) = preSolution
1226
HideSolutionNode = FALSE
1327
EndGlobalSection
28+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
29+
{F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{F7E4AE8C-8398-461B-AB82-CF7BCE1EB22A}.Release|Any CPU.Build.0 = Release|Any CPU
33+
EndGlobalSection
1434
EndGlobal

CodeStyle/CodeStyle.csproj

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.Build.NoTargets">
3+
<PropertyGroup>
4+
<Version>1.0.0</Version>
5+
<PackageId>Polyadic.CodeStyle</PackageId>
6+
<PackageTags>analyzers</PackageTags>
7+
<Description>Various analyzers bundled with opinionated configuration</Description>
8+
<NoWarn>$(NoWarn);NU5104;NU5128</NoWarn>
9+
<!-- NU5104: A stable release of a package should not have a prerelease dependency.
10+
See https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5104 -->
11+
<!-- NU5128: Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location.
12+
See https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128 -->
13+
</PropertyGroup>
14+
<PropertyGroup>
15+
<TargetFramework>netstandard2.0</TargetFramework>
16+
</PropertyGroup>
17+
<ItemGroup>
18+
<PackageReference Include="IDisposableAnalyzers" Version="4.0.2" PrivateAssets="none" />
19+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="none" />
20+
</ItemGroup>
21+
<ItemGroup>
22+
<None Include="build\**\*">
23+
<Pack>true</Pack>
24+
<PackagePath>%(Identity)</PackagePath>
25+
</None>
26+
</ItemGroup>
27+
</Project>

CodeStyle/build/Default.ruleset

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Default rules for all Polyadic projects" ToolsVersion="10.0">
3+
<Include Path="Disposable.ruleset" Action="Default" />
4+
<Include Path="StyleCop.ruleset" Action="Default" />
5+
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
6+
<Rule Id="CS1591" Action="None" /> <!-- Missing XML comment for publicly visible type or member 'Type_or_Member' -->
7+
</Rules>
8+
</RuleSet>

CodeStyle/build/Disposable.ruleset

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Rules for IDisposable Analyzers" ToolsVersion="10.0">
3+
<Rules AnalyzerId="IDisposableAnalyzers.Correctness" RuleNamespace="IDisposableAnalyzers.Correctness">
4+
<Rule Id="IDISP001" Action="Error" />
5+
<Rule Id="IDISP002" Action="Error" />
6+
<Rule Id="IDISP003" Action="Error" />
7+
<Rule Id="IDISP004" Action="Error" />
8+
<Rule Id="IDISP005" Action="Error" />
9+
<Rule Id="IDISP006" Action="Error" />
10+
<Rule Id="IDISP007" Action="Error" />
11+
<Rule Id="IDISP008" Action="Error" />
12+
<Rule Id="IDISP009" Action="Error" />
13+
<Rule Id="IDISP010" Action="Error" />
14+
<Rule Id="IDISP011" Action="Error" />
15+
<Rule Id="IDISP012" Action="Error" />
16+
<Rule Id="IDISP013" Action="Warning" />
17+
<Rule Id="IDISP014" Action="Error" />
18+
<Rule Id="IDISP015" Action="Error" />
19+
<Rule Id="IDISP016" Action="Error" />
20+
<Rule Id="IDISP017" Action="Error" />
21+
<Rule Id="IDISP018" Action="Error" />
22+
<Rule Id="IDISP019" Action="Error" />
23+
<Rule Id="IDISP020" Action="Error" />
24+
<Rule Id="IDISP021" Action="Error" />
25+
<Rule Id="IDISP022" Action="Error" />
26+
<Rule Id="IDISP023" Action="Error" />
27+
</Rules>
28+
</RuleSet>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
is_global = true
2+
3+
dotnet_diagnostic.IDE0005.severity = warning # IDE0005: Using directive is unnecessary.
4+
csharp_style_namespace_declarations = file_scoped:error
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Default.ruleset</CodeAnalysisRuleSet>
5+
<WarningsAsErrors Condition="'$(MSBuildProjectExtension)' == '.csproj'">$(WarningsAsErrors);nullable</WarningsAsErrors>
6+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild><!-- This is needed to enable IDE* rules during build. -->
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile><!-- This is needed so that analyzers can inspect XML comments. Enforced by SA0001. -->
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" Visible="false" InProject="false" />
11+
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)Polyadic.CodeStyle.editorconfig" />
12+
</ItemGroup>
13+
</Project>

0 commit comments

Comments
 (0)