Skip to content

Commit 4b07eb6

Browse files
Merge pull request #156 from atc-net/feature/project_frameworks
Introduce support for project specific framework types
2 parents df49af9 + 1c16711 commit 4b07eb6

23 files changed

+167
-49
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ dotnet_diagnostic.S1135.severity = suggestion # https://github.com/atc-net
518518

519519
dotnet_diagnostic.IDE0057.severity = none # Substring can be simplified
520520

521+
dotnet_diagnostic.SA1010.severity = none #
522+
521523
dotnet_diagnostic.CA1054.severity = none # URI parameters should not be strings
522524
dotnet_diagnostic.CA1848.severity = none # For improved performance, use the LoggerMessage delegates instead of calling 'LoggerExtensions.LogTrace(ILogger, string, params object[])'
523525
dotnet_diagnostic.CA1859.severity = none #

README.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This repository contains a CLI tool, which can be used to maintain `coding-rules
2323
- [Options file schema / example](#options-file-schema--example)
2424
- [atc-coding-rules-updater.json example 1](#atc-coding-rules-updaterjson-example-1)
2525
- [atc-coding-rules-updater.json example 2](#atc-coding-rules-updaterjson-example-2)
26+
- [atc-coding-rules-updater.json example 3](#atc-coding-rules-updaterjson-example-3)
2627
- [atc-coding-rules-updater.json default](#atc-coding-rules-updaterjson-default)
2728
- [CLI Tool Usage from powershell](#cli-tool-usage-from-powershell)
2829
- [Deep dive in what `atc-coding-rules-updater` actual does and doesn't do](#deep-dive-in-what-atc-coding-rules-updater-actual-does-and-doesnt-do)
@@ -80,8 +81,8 @@ USAGE:
8081
8182
OPTIONS:
8283
-h, --help Prints help information
83-
-v, --verbose Use verbose for more debug/trace information
84-
--version Display version
84+
--verbose Use verbose for more debug/trace information
85+
-v, --version Display version
8586
8687
COMMANDS:
8788
run Update the project folder with ATC coding rules and configurations
@@ -101,11 +102,11 @@ EXAMPLES:
101102
atc-coding-rules-updater.exe run -p . (equivalent to 'run -p [CurrentFolder]')
102103
atc-coding-rules-updater.exe run -p c:\temp\MyProject
103104
atc-coding-rules-updater.exe run -p c:\temp\MyProject -t DotNetCore --useTemporarySuppressions --organizationName
104-
MyCompany --repositoryName MyRepo -v
105+
MyCompany --repositoryName MyRepo --verbose
105106
106107
OPTIONS:
107108
-h, --help Prints help information
108-
-v, --verbose Use verbose for more debug/trace information
109+
--verbose Use verbose for more debug/trace information
109110
-p, --projectPath <PROJECTPATH> Path to the project directory (default current
110111
diectory)
111112
-o, --optionsPath [OPTIONSPATH] Path to an optional options json-file
@@ -136,11 +137,11 @@ USAGE:
136137
EXAMPLES:
137138
atc-coding-rules-updater.exe sanity-check . (equivalent to 'sanity-check -p [CurrentFolder]')
138139
atc-coding-rules-updater.exe sanity-check -p c:\temp\MyProject
139-
atc-coding-rules-updater.exe sanity-check -p c:\temp\MyProject -t DotNetCore -v
140+
atc-coding-rules-updater.exe sanity-check -p c:\temp\MyProject -t DotNetCore --verbose
140141
141142
OPTIONS:
142143
-h, --help Prints help information
143-
-v, --verbose Use verbose for more debug/trace information
144+
--verbose Use verbose for more debug/trace information
144145
-p, --projectPath <PROJECTPATH> Path to the project directory (default current diectory)
145146
-o, --optionsPath [OPTIONSPATH] Path to an optional options json-file
146147
-t, --projectTarget [PROJECTTARGET] Sets the ProjectTarget. Valid values are: DotNetCore, DotNet5, DotNet6, DotNet7, DotNet8 (default)
@@ -172,7 +173,7 @@ COMMANDS:
172173
Having a project folder in c:\code\MyProject where the .sln file for C# projects exists in the root, run the following command
173174

174175
```powershell
175-
atc-coding-rules-updater run -p c:\code\MyProject -v
176+
atc-coding-rules-updater run -p c:\code\MyProject --verbose
176177
```
177178

178179
Running the command above produces the following output
@@ -201,6 +202,8 @@ Running the command above produces the following output
201202

202203
The tool has an optional options parameter, which can be used to control the paths for persisting the .editorconfigs and props files. This can be applied as follows `--optionsPath 'C:\Temp\atc-coding-rules-updater.json'`
203204

205+
By default the atc-coding-rules-updater will detect projects in the solution and try to fetch the matching project specific rules and supply an .editorconfig in those projects. This mapping can however be over-ruled as seen in [atc-coding-rules-updater.json example 3](#atc-coding-rules-updaterjson-example-3)
206+
204207
### atc-coding-rules-updater.json example 1
205208

206209
```json
@@ -237,6 +240,29 @@ The tool has an optional options parameter, which can be used to control the pat
237240
}
238241
```
239242

243+
### atc-coding-rules-updater.json example 3
244+
245+
In this example a project framework mapping has been added. The entry is mapped using the CsProj fileName and the specific ProjectFrameworkType. Currently the supported values for project framework type are [defined here](/src/Atc.CodingRules.Updater/ProjectFrameworkType.cs)
246+
247+
By specifying this mapping it will over-rule the automatic detection of the project framework type.
248+
249+
```json
250+
{
251+
"projectTarget": "DotNet8",
252+
"mappings": {
253+
"sample": { "paths": [ "sample" ] },
254+
"src": { "paths": [ "src" ] },
255+
"test": { "paths": [ "test" ] }
256+
},
257+
"projectFrameworkMappings": [
258+
{
259+
"name": "HelloWorldWpf",
260+
"type": "Wpf"
261+
}
262+
]
263+
}
264+
```
265+
240266
### atc-coding-rules-updater.json default
241267

242268
```json
@@ -257,7 +283,8 @@ The tool has an optional options parameter, which can be used to control the pat
257283
"test"
258284
]
259285
}
260-
}
286+
},
287+
"projectFrameworkMappings": []
261288
}
262289
```
263290

atc-coding-rules-updater.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ atc-coding-rules-updater `
99
run `
1010
-p $currentPath `
1111
--optionsPath $currentPath'\atc-coding-rules-updater.json' `
12-
-v
12+
--verbose

src/Atc.CodingRules.AnalyzerProviders/Atc.CodingRules.AnalyzerProviders.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Atc" Version="2.0.433" />
13-
<PackageReference Include="HtmlAgilityPack" Version="1.11.59" />
12+
<PackageReference Include="Atc" Version="2.0.442" />
13+
<PackageReference Include="HtmlAgilityPack" Version="1.11.60" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

src/Atc.CodingRules.AnalyzerProviders/GlobalUsings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
global using System.Diagnostics.CodeAnalysis;
66
global using System.IO;
77
global using System.Linq;
8+
global using System.Net;
89
global using System.Text.Encodings.Web;
910
global using System.Text.Json;
1011
global using System.Text.Json.Serialization;

src/Atc.CodingRules.AnalyzerProviders/Providers/AnalyzerProviderBase.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Net;
2-
31
namespace Atc.CodingRules.AnalyzerProviders.Providers;
42

53
public abstract class AnalyzerProviderBase : IAnalyzerProvider

src/Atc.CodingRules.Updater.CLI/Atc.CodingRules.Updater.CLI.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Atc" Version="2.0.433" />
17-
<PackageReference Include="Atc.Console.Spectre" Version="2.0.433" />
18-
<PackageReference Include="EPPlus" Version="7.0.10" />
16+
<PackageReference Include="Atc" Version="2.0.442" />
17+
<PackageReference Include="Atc.DotNet" Version="2.0.442" />
18+
<PackageReference Include="Atc.Console.Spectre" Version="2.0.442" />
19+
<PackageReference Include="EPPlus" Version="7.1.0" />
1920
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
2021
</ItemGroup>
2122

src/Atc.CodingRules.Updater.CLI/Commands/OptionsFileCreateCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ public class OptionsFileCreateCommand : AsyncCommand<ProjectCommandSettings>
44
{
55
private readonly ILogger<OptionsFileCreateCommand> logger;
66

7-
public OptionsFileCreateCommand(ILogger<OptionsFileCreateCommand> logger) => this.logger = logger;
7+
public OptionsFileCreateCommand(
8+
ILogger<OptionsFileCreateCommand> logger)
9+
=> this.logger = logger;
810

911
public override Task<int> ExecuteAsync(
1012
CommandContext context,

src/Atc.CodingRules.Updater.CLI/Commands/OptionsFileValidateCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ public class OptionsFileValidateCommand : AsyncCommand<ProjectBaseCommandSetting
44
{
55
private readonly ILogger<OptionsFileValidateCommand> logger;
66

7-
public OptionsFileValidateCommand(ILogger<OptionsFileValidateCommand> logger) => this.logger = logger;
7+
public OptionsFileValidateCommand(
8+
ILogger<OptionsFileValidateCommand> logger)
9+
=> this.logger = logger;
810

911
public override Task<int> ExecuteAsync(
1012
CommandContext context,

src/Atc.CodingRules.Updater.CLI/Commands/RunCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ public class RunCommand : AsyncCommand<RunCommandSettings>
66
{
77
private readonly ILogger<RunCommand> logger;
88

9-
public RunCommand(ILogger<RunCommand> logger) => this.logger = logger;
9+
public RunCommand(
10+
ILogger<RunCommand> logger)
11+
=> this.logger = logger;
1012

1113
public override Task<int> ExecuteAsync(
1214
CommandContext context,

0 commit comments

Comments
 (0)