Skip to content

Commit 8d8e148

Browse files
Merge pull request #22 from TimeWarpEngineering/Cramer/2025-07-31/filename-rule
Refactor analyzer IDs and remove HelloWorld generator
2 parents 152fbf6 + 7dd56ec commit 8d8e148

File tree

15 files changed

+41
-120
lines changed

15 files changed

+41
-120
lines changed

.editorconfig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,8 @@ dotnet_naming_style.local_function_style.capitalization = pascal_case
274274

275275
# dotnet_diagnostic options
276276
dotnet_diagnostic.CS1591.severity = none
277-
dotnet_diagnostic.TW0001.severity = suggestion
278-
dotnet_diagnostic.TWD001.severity = warning
279-
dotnet_diagnostic.TW0003.severity = none # Set to warning/error to enforce kebab-case file naming
280-
dotnet_diagnostic.TW0003.excluded_files = *.g.cs;*.Generated.cs;*.generated.cs;*.designer.cs;*.Designer.cs;Directory.Build.props;Directory.Build.targets;Directory.Packages.props;AssemblyInfo.cs;*.AssemblyAttributes.cs;AnalyzerReleases.Shipped.md;AnalyzerReleases.Unshipped.md
277+
dotnet_diagnostic.TWA001.severity = none # Set to warning/error to enforce kebab-case file naming
278+
dotnet_diagnostic.TWA001.excluded_files = *.g.cs;*.Generated.cs;*.generated.cs;*.designer.cs;*.Designer.cs;*.razor.cs;Directory.Build.props;Directory.Build.targets;Directory.Packages.props;AssemblyInfo.cs;*.AssemblyAttributes.cs;AnalyzerReleases.Shipped.md;AnalyzerReleases.Unshipped.md
281279

282280
#### Analyzer settings ####
283281
dotnet_code_quality.null_check_validation_methods = NotNull

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Authors>Steven T. Cramer</Authors>
66
<Product>TimeWarp.SourceGenerators</Product>
77
<PackageId>TimeWarp.SourceGenerators</PackageId>
8-
<PackageVersion>1.0.0-beta.3</PackageVersion>
8+
<PackageVersion>1.0.0-beta.4</PackageVersion>
99
<PackageProjectUrl>https://timewarpengineering.github.io/timewarp-source-generators/</PackageProjectUrl>
1010
<PackageTags>TimeWarp; Source Generator;SourceGenerators; Delegate</PackageTags>
1111
<PackageIcon>logo.png</PackageIcon>

documentation/developer/conceptual/analyzer-release-tracking.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ AnalyzerReleases.Unshipped.md:
7171
### New Rules
7272
Rule ID | Category | Severity | Notes
7373
--------|----------|----------|-------
74-
TW0001 | SourceGenerator | Info | HelloWorldGenerator
75-
TW0002 | SourceGenerator | Info | MarkdownDocsGenerator
76-
TW0003 | Naming | Info | FileNameRuleAnalyzer, disabled by default
74+
TWG001 | SourceGenerator | Info | MarkdownDocsGenerator
75+
TWA001 | Naming | Info | FileNameRuleAnalyzer, disabled by default
76+
TWA002 | Documentation | Info | XmlDocsToMarkdownAnalyzer
7777
7878
AnalyzerReleases.Shipped.md:
7979
## Release 1.0

documentation/developer/reference/analyzers/file-name-rule-analyzer.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# FileNameRuleAnalyzer (TW0003)
1+
# FileNameRuleAnalyzer (TWA001)
22

33
## Overview
44

55
The FileNameRuleAnalyzer enforces kebab-case naming conventions for C# source files. This analyzer helps maintain consistent file naming across projects that prefer kebab-case (e.g., `my-component.cs`) over traditional PascalCase.
66

77
## Rule Details
88

9-
- **Rule ID**: TW0003
9+
- **Rule ID**: TWA001
1010
- **Category**: Naming
1111
- **Default Severity**: Info (disabled by default)
1212
- **Message**: File '{0}' should use kebab-case naming convention (e.g., 'my-file.cs')
@@ -41,25 +41,26 @@ The analyzer is disabled by default to avoid breaking existing projects. To enab
4141

4242
```ini
4343
# Enable with warning severity
44-
dotnet_diagnostic.TW0003.severity = warning
44+
dotnet_diagnostic.TWA001.severity = warning
4545

4646
# Or as an error to fail builds
47-
dotnet_diagnostic.TW0003.severity = error
47+
dotnet_diagnostic.TWA001.severity = error
4848

4949
# Or as a suggestion for gentle nudging
50-
dotnet_diagnostic.TW0003.severity = suggestion
50+
dotnet_diagnostic.TWA001.severity = suggestion
5151
```
5252

5353
### Exception Patterns
5454

5555
Configure files that should be excluded from the rule:
5656

5757
```ini
58-
dotnet_diagnostic.TW0003.excluded_files = *.g.cs;*.Generated.cs;GlobalUsings.cs;Program.cs;Startup.cs
58+
dotnet_diagnostic.TWA001.excluded_files = *.g.cs;*.Generated.cs;GlobalUsings.cs;Program.cs;Startup.cs
5959
```
6060

6161
Default exceptions include:
6262
- Generated files (`*.g.cs`, `*.Generated.cs`, `*.designer.cs`)
63+
- Razor component code-behind files (`*.razor.cs`) - must match their `.razor` file names
6364
- Build files (`Directory.Build.props`, `Directory.Build.targets`, `Directory.Packages.props`)
6465
- Assembly metadata (`AssemblyInfo.cs`)
6566
- Analyzer tracking files (`AnalyzerReleases.Shipped.md`, `AnalyzerReleases.Unshipped.md`)
@@ -87,10 +88,10 @@ In your root `.editorconfig`:
8788
```ini
8889
[*.cs]
8990
# Enable kebab-case file naming for all C# files
90-
dotnet_diagnostic.TW0003.severity = warning
91+
dotnet_diagnostic.TWA001.severity = warning
9192

9293
# But allow exceptions for specific patterns
93-
dotnet_diagnostic.TW0003.excluded_files = *.g.cs;*.Generated.cs;*.designer.cs;Program.cs;Startup.cs;GlobalUsings.cs;AssemblyInfo.cs
94+
dotnet_diagnostic.TWA001.excluded_files = *.g.cs;*.Generated.cs;*.designer.cs;Program.cs;Startup.cs;GlobalUsings.cs;AssemblyInfo.cs
9495
```
9596

9697
### Gradual Adoption
@@ -99,29 +100,29 @@ For existing projects, start with suggestion severity:
99100

100101
```ini
101102
[*.cs]
102-
dotnet_diagnostic.TW0003.severity = suggestion
103+
dotnet_diagnostic.TWA001.severity = suggestion
103104

104105
# Only enforce in new feature folders
105106
[Features/**.cs]
106-
dotnet_diagnostic.TW0003.severity = warning
107+
dotnet_diagnostic.TWA001.severity = warning
107108
```
108109

109110
## Suppressing Violations
110111

111112
For specific files that need exceptions beyond the configured patterns:
112113

113114
```csharp
114-
#pragma warning disable TW0003 // File name should use kebab-case
115+
#pragma warning disable TWA001 // File name should use kebab-case
115116
// File: LegacyAPIClient.cs
116-
#pragma warning restore TW0003
117+
#pragma warning restore TWA001
117118
```
118119

119120
Or in the project file:
120121

121122
```xml
122123
<ItemGroup>
123124
<Compile Update="LegacyAPIClient.cs">
124-
<AnalyzerSuppression>TW0003</AnalyzerSuppression>
125+
<AnalyzerSuppression>TWA001</AnalyzerSuppression>
125126
</Compile>
126127
</ItemGroup>
127128
```

documentation/developer/reference/analyzers/overview.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
## Available Analyzers
44

5-
### TW0003 - File Name Rule Analyzer
5+
### TWA001 - File Name Rule Analyzer
66

77
Enforces kebab-case naming convention for C# source files.
88

9-
- **Rule ID**: TW0003
9+
- **Rule ID**: TWA001
1010
- **Category**: Naming
1111
- **Default Severity**: Info (disabled)
1212
- **Configuration**: `.editorconfig`
@@ -19,10 +19,10 @@ All analyzers are configured through `.editorconfig`:
1919

2020
```ini
2121
# Enable an analyzer
22-
dotnet_diagnostic.TW0003.severity = warning
22+
dotnet_diagnostic.TWA001.severity = warning
2323

2424
# Configure exceptions
25-
dotnet_diagnostic.TW0003.excluded_files = *.g.cs;*.Generated.cs
25+
dotnet_diagnostic.TWA001.excluded_files = *.g.cs;*.Generated.cs
2626
```
2727

2828
## Analyzer Categories
@@ -34,15 +34,15 @@ dotnet_diagnostic.TW0003.excluded_files = *.g.cs;*.Generated.cs
3434

3535
1. **File-level pragma**:
3636
```csharp
37-
#pragma warning disable TW0003
37+
#pragma warning disable TWA001
3838
```
3939

4040
2. **Project-wide**:
4141
```xml
42-
<NoWarn>TW0003</NoWarn>
42+
<NoWarn>TWA001</NoWarn>
4343
```
4444

4545
3. **EditorConfig**:
4646
```ini
47-
dotnet_diagnostic.TW0003.severity = none
47+
dotnet_diagnostic.TWA001.severity = none
4848
```

documentation/developer/reference/source-generators/overview.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22

33
## Available Source Generators
44

5-
### HelloWorldGenerator (TW0001)
6-
7-
A simple demonstration source generator that creates a static class with a hello message.
8-
9-
- **Generated File**: `HelloWorld.g.cs`
10-
- **Namespace**: `TimeWarp.Generated`
11-
- **Diagnostic**: Info message when loaded
12-
13-
### MarkdownDocsGenerator (TW0002)
5+
### MarkdownDocsGenerator (TWG001)
146

157
Generates XML documentation from markdown files for C# classes.
168

documentation/overview.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ Technical documentation for developers using or contributing to the project.
1414
## What's Included
1515

1616
### Source Generators
17-
- **HelloWorldGenerator** - Example generator
1817
- **MarkdownDocsGenerator** - Generates markdown from XML docs
1918

2019
### Analyzers
21-
- **TW0003** - File name kebab-case enforcement
20+
- **TWA001** - File name kebab-case enforcement
2221

2322
## Configuration
2423

source/timewarp-source-generators/AnalyzerReleases.Unshipped.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
Rule ID | Category | Severity | Notes
44
--------|----------|----------|-------
5-
TW0001 | SourceGenerator | Info | HelloWorldGenerator
6-
TW0002 | SourceGenerator | Info | MarkdownDocsGenerator - Enhanced to support kebab-case file matching
7-
TW0003 | Naming | Info | FileNameRuleAnalyzer, disabled by default
8-
TW0004 | Documentation | Info | XmlDocsToMarkdownAnalyzer
5+
TWG001 | SourceGenerator | Info | MarkdownDocsGenerator - Enhanced to support kebab-case file matching
6+
TWA001 | Naming | Info | FileNameRuleAnalyzer, disabled by default
7+
TWA002 | Documentation | Info | XmlDocsToMarkdownAnalyzer

source/timewarp-source-generators/file-name-rule-analyzer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace TimeWarp.SourceGenerators;
33
[Generator]
44
public class FileNameRuleAnalyzer : IIncrementalGenerator
55
{
6-
public const string DiagnosticId = "TW0003";
6+
public const string DiagnosticId = "TWA001";
77
private const string Category = "Naming";
88

99
private static readonly DiagnosticDescriptor Rule = new(
@@ -27,6 +27,7 @@ public class FileNameRuleAnalyzer : IIncrementalGenerator
2727
"*.generated.cs",
2828
"*.designer.cs",
2929
"*.Designer.cs",
30+
"*.razor.cs", // Razor component code-behind files must match their .razor file names
3031
"Directory.Build.props",
3132
"Directory.Build.targets",
3233
"Directory.Packages.props",
@@ -98,7 +99,7 @@ private string[] GetConfiguredExceptions(AnalyzerConfigOptionsProvider configOpt
9899

99100
// Try to get configured exceptions from .editorconfig
100101
if (options.TryGetValue(
101-
"dotnet_diagnostic.TW0003.excluded_files",
102+
"dotnet_diagnostic.TWA001.excluded_files",
102103
out string? configuredExceptions) && !string.IsNullOrEmpty(configuredExceptions))
103104
{
104105
// Split by semicolon and trim whitespace

source/timewarp-source-generators/hello-world-generator.cs

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)