Compare commits

..

20 Commits

Author SHA1 Message Date
b2e46fe7a7 🔧 Enables SBOM generation only for packable projects 2026-02-15 15:27:45 +02:00
4119b8c82b 🔧 Updates StyleCop configuration to place using directives outside namespace and removes delegate from top-level types 2026-02-15 15:27:45 +02:00
a15f35aeb8 🔧 Fixes case sensitive path for linux 2026-02-15 15:27:45 +02:00
ab849a8d3b ⬆️ Updates package versions in Directory.Packages.props 2026-02-15 15:27:45 +02:00
50d7e11c16 🔧 Removes deprecated IncludeOpenAPIAnalyzers property 2026-02-15 15:27:45 +02:00
df744087d4 🔧 Adds ruleset for common Roslyn analyzer configuration 2026-02-15 15:27:44 +02:00
6e9450fbf5 🔧 Aligns stylecop rules with C# config 2026-02-15 15:27:44 +02:00
67801c3795 📝 Exposes stylecop.json on the solution 2026-02-15 15:27:44 +02:00
250b6fc5ed 🔧 Updates packaging configuration for README and icon files 2026-02-15 15:27:44 +02:00
6c3c274de5 🔧 Fixes condition for including README in NuGet package 2026-02-15 15:27:44 +02:00
45f6e66174 🔧 Excludes stylecop.json from package outputs 2026-02-15 15:27:44 +02:00
5e9b6ab9de 🔧 Fixes project icon and README paths 2026-02-15 15:27:44 +02:00
0fd028eff6 🔧 Updates Stylecop configuration to use AdditionalFiles instead of Content
This lead to stylecop.json files being published alongside the nugets
2026-02-15 15:27:43 +02:00
286d8fdc7e 🔧 Adds PackageReference for Microsoft.Sbom.Targets 2026-02-15 15:27:43 +02:00
6ad3aac084 Adds Stylecop replacement package 2026-02-15 15:27:43 +02:00
09668de51c 💄 Basic styling guide for stylecop 2026-02-15 15:27:43 +02:00
7df22a4413 🔧 Set Configuration analysis if it hasn't been overriden 2026-02-15 15:27:43 +02:00
37603dedf2 🔧 Uses Stylecop configuration if present 2026-02-15 15:27:43 +02:00
f3a4c804b7 🔧 Disable source generated files 2026-02-15 15:27:43 +02:00
02d5746360 🔧 Adds SBOM for nuget packages 2026-02-15 15:27:43 +02:00
5 changed files with 102 additions and 15 deletions

View File

@@ -33,6 +33,7 @@
<AnalysisLevel>preview</AnalysisLevel>
<AnalysisMode>All</AnalysisMode>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<CodeAnalysisTreatWarningsAsErrors Condition="$(CodeAnalysisTreatWarningsAsErrors) == ''">false</CodeAnalysisTreatWarningsAsErrors>
<!-- Locked mode should only be enabled on CI -->
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</RestoreLockedMode>
<!-- Use deterministic builds -->
@@ -45,7 +46,7 @@
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ApplicationVisualStyles>true</ApplicationVisualStyles>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<EmitCompilerGeneratedFiles>false</EmitCompilerGeneratedFiles>
<GenerateRequiresPreviewFeaturesAttribute>False</GenerateRequiresPreviewFeaturesAttribute>
<DefaultItemExcludes>$(DefaultItemExcludes);*.log;*.binlog</DefaultItemExcludes>
</PropertyGroup>
@@ -67,18 +68,18 @@
<PropertyGroup Label="Project Assets">
<ProjectIcon Condition="Exists('$(MSBuildThisFileDirectory)\icon.png')">
$(MSBuildThisFileDirectory)\icon.png
$(MSBuildThisFileDirectory)icon.png
</ProjectIcon>
<ProjectIcon Condition="Exists('$(MSBuildProjectDirectory)\icon.png')">
$(MSBuildProjectDirectory)\icon.png
$(MSBuildProjectDirectory)icon.png
</ProjectIcon>
<ProjectIconExists Condition="$(ProjectIcon) != ''">true</ProjectIconExists>
<ProjectReadMe Condition="Exists('$(MSBuildThisFileDirectory)\README.md')">
$(MSBuildThisFileDirectory)\README.md
$(MSBuildThisFileDirectory)README.md
</ProjectReadMe>
<ProjectReadMe Condition="Exists('$(MSBuildProjectDirectory)\README.md')">
$(MSBuildProjectDirectory)\README.md
$(MSBuildProjectDirectory)README.md
</ProjectReadMe>
<ProjectReadMeExists Condition="$(ProjectReadMe) != ''">true</ProjectReadMeExists>
</PropertyGroup>
@@ -95,7 +96,6 @@
</PropertyGroup>
<PropertyGroup Label="OpenAPI Analyzers" Condition="'$(UsingMicrosoftNETSdkWeb)' == 'True'">
<IncludeOpenAPIAnalyzers>true</IncludeOpenAPIAnalyzers>
<OpenApiDocumentsDirectory>$(MSBuildProjectDirectory)/OpenApi</OpenApiDocumentsDirectory>
</PropertyGroup>
@@ -130,6 +130,7 @@
<!-- Mark assemblies as CLS compliant so the compiler warns on non compliant usage -->
<PropertyGroup Condition="$(IsPackable) == 'true'">
<ClsCompliant>true</ClsCompliant>
<GenerateSBOM>true</GenerateSBOM>
</PropertyGroup>
<ItemGroup>
<AssemblyAttribute Include="System.CLSCompliant">
@@ -145,13 +146,13 @@
</PropertyGroup>
<!-- Use readme as nuget information -->
<ItemGroup Label="Readme" Condition="$(IsPackable) == 'True' AND $(ProjectReadMe) != ''">
<None Include="$(ProjectReadMe)" Pack="true" PackagePath="" Visible="true"/>
<ItemGroup Label="Readme" Condition="$(IsPackable) == 'True' AND $(ProjectReadMeExists) == 'True'">
<Content Include="$(ProjectReadMe)" PackagePath="README.md" />
</ItemGroup>
<!-- Use nuget icon -->
<ItemGroup Label="Icon" Condition="$(IsPackable) == 'True' AND $(ProjectIconExists) == 'True'">
<None Include="$(ProjectIcon)" Pack="true" PackagePath="icon.png" Visible="false"/>
<Content Include="$(ProjectIcon)" Pack="true" PackagePath="icon.png" Visible="false"/>
</ItemGroup>
<!-- Uses pretty xUnit configuration -->
@@ -160,6 +161,12 @@
<Content Include="$(MSBuildThisFileDirectory)\xunit.runner.json" Link="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" Visible="false" />
</ItemGroup>
<ItemGroup Label="Stylecop Configuration"
Condition="Exists('$(MSBuildThisFileDirectory)\stylecop.json')">
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\stylecop.json" Link="stylecop.json"
CopyToOutputDirectory="Never" Visible="false" />
</ItemGroup>
<!-- Project internals are exposed to projects named $(Project).Tests by default -->
<ItemGroup
Condition="@(InternalsVisibleToSuffix->Count()) == 0 AND @(InternalsVisibleTo->Count()) == 0">
@@ -200,6 +207,13 @@
</PackageReference>
</ItemGroup>
<ItemGroup Label="Analyzers">
<PackageReference Include="NewStyleCop.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Label="Test Frameworks" Condition="'$(IsTestProject)' == 'true'">
<PackageReference Include="NSubstitute"/>
<PackageReference Include="NSubstitute.Analyzers.CSharp">
@@ -210,6 +224,7 @@
<ItemGroup Label="SourceLink" Condition="$(IsPackable) == 'true'">
<SourceLinkGiteaHost Include="git.kritikos.io"/>
<PackageReference Include="Microsoft.Sbom.Targets" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@@ -1,11 +1,13 @@
<Project>
<ItemGroup Label="Packages">
<PackageVersion Include="GitVersion.MsBuild" Version="6.4.0" />
<PackageVersion Include="GitVersion.MsBuild" Version="6.5.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.6" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Microsoft.Sbom.Targets" Version="4.1.3" />
<PackageVersion Include="NewStyleCop.Analyzers" Version="1.2.0" />
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="xunit.v3" Version="2.0.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="xunit.v3" Version="3.2.0" />
</ItemGroup>
</Project>

View File

@@ -14,15 +14,16 @@
<File Path="Directory.Packages.props" />
<File Path="dotnet.ruleset" />
<File Path="GitVersion.yml" />
<File Path="stylecop.json" />
<File Path="xunit.runner.json" />
</Folder>
<Folder Name="/samples/">
<File Path="samples\Directory.Build.props" />
</Folder>
<Folder Name="/src/">
<File Path="src\Directory.build.props" />
<File Path="src\Directory.Build.props" />
</Folder>
<Folder Name="/tests/">
<File Path="tests\Directory.Build.props" />
</Folder>
</Solution>
</Solution>

22
dotnet.ruleset Normal file
View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Kritikos Ruleset" Description="Common roslyn analyser configuration" ToolsVersion="10.0">
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
<Rule Id="CS1573" Action="None" />
<Rule Id="CS1591" Action="None" />
<Rule Id="CS2008" Action="None" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeQuality.Analyzers" RuleNamespace="Microsoft.CodeQuality.Analyzers">
<Rule Id="CA1303" Action="None" />
<Rule Id="CA1848" Action="None" />
<Rule Id="CA2007" Action="None" />
<Rule Id="CA1707" Action="None" />
</Rules>
<Rules AnalyzerId="SerilogAnalyzer" RuleNamespace="SerilogAnalyzer">
<Rule Id="Serilog004" Action="None" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1101" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SA1649" Action="None" />
</Rules>
</RuleSet>

47
stylecop.json Normal file
View File

@@ -0,0 +1,47 @@
{
"$schema": "https://raw.githubusercontent.com/bjornhellander/NewStyleCopAnalyzers/refs/heads/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"indentation": {
"useTabs": false,
"indentationSize": 2
},
"orderingRules": {
"usingDirectivesPlacement": "outsideNamespace",
"systemUsingDirectivesFirst": true,
"blankLinesBetweenUsingGroups": "require",
"elementOrder": [
"kind",
"accessibility",
"constant",
"static",
"readonly"
]
},
"maintainabilityRules": {
"topLevelTypes": [
"class",
"interface",
"struct",
"enum"
]
},
"namingRules": {
"allowCommonHungarianPrefixes": false,
"includeInferredTupleElementNames": true,
"tupleElementNameCasing": "PascalCase"
},
"layoutRules": {
"newlineAtEndOfFile": "require",
"allowConsecutiveUsings": false,
"allowDoWhileOnClosingBrace": true
},
"readabilityRules": {
"allowBuiltInTypeAliases": false
},
"documentationRules": {
"documentExposedElements": true,
"documentationCulture": "en-US",
"documentInterfaces": true
}
}
}