Skip to content

Commit 55bb2bf

Browse files
committed
Add README and Diagnostic IDs reservations file
1 parent ee43e6d commit 55bb2bf

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

DiagnosticCategoryAndIdRanges.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This file contains the allowed analyzer rule "Category" and corresponding "Diagnostic ID range"
2+
# FORMAT:
3+
# 'Category': Comma separate list of 'StartId-EndId' or 'Id' or 'Prefix'
4+
5+
#
6+
# The ranges below represent the **currently used IDs** for the corresponding category.
7+
# When implementing a new rule for the category, BEFORE submitting a PR:
8+
# 1. Choose the rule ID immediately following the range end.
9+
# 2. Update the range end to the chosen rule ID.
10+
# 3. Commit and push the change to this file to `main`, with this file being the only file in the commit.
11+
# 4. Your rule ID is now reserved and can be used in your PR.
12+
#
13+
# In the event of conflict in step 3, make sure you discard your changes, pull latest, and try again.
14+
# DO NOT remove ID ranges already defined or merge this file in git.
15+
#
16+
Design: LuceneDev1000-LuceneDev1004
17+
Globalization:
18+
Mobility:
19+
Performance:
20+
Security:
21+
Usage:
22+
Naming:
23+
Interoperability:
24+
Maintainability:
25+
Reliability:
26+
Documentation:

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Apache Lucene.NET Dev Analyzers
2+
3+
This repo contains custom [Roslyn analyzers](https://learn.microsoft.com/en-us/visualstudio/code-quality/roslyn-analyzers-overview?view=vs-2022) that are used by the [Apache Lucene.NET](https://lucenenet.apache.org/) project to enforce code quality and consistency, as well as provide automated code fixes.
4+
5+
These analyzers are intended for use by contributors to the Lucene.NET project only.
6+
They are not intended for public use outside of this project.
7+
Therefore, any releases or NuGet packages produced from this repository are not official Apache Lucene.NET project artifacts, and are not subject to the same quality control or testing as the official Lucene.NET releases.
8+
They are also not subject to the release policy or voting process, as these are not intended
9+
to be used "beyond the group that owns it."
10+
11+
## Building
12+
13+
To build the analyzers, you will need to have the [.NET 8 SDK](https://dotnet.microsoft.com/download) installed.
14+
15+
To build from the repo root, run the following command:
16+
17+
```bash
18+
dotnet build
19+
```
20+
21+
To run the tests, you can use the following command:
22+
23+
```bash
24+
dotnet test
25+
```
26+
27+
## IDE Support and Debugging
28+
29+
These analyzers have been tested with Visual Studio 2022 and JetBrains Rider. They should work with any IDE that supports Roslyn analyzers, but your mileage may vary. Importantly, they also work with MSBuild, so they can be used in our CI pipelines, or to help validate your changes when you build before submitting a pull request.
30+
31+
A `Lucene.Net.CodeAnalysis.Dev.Sample` project has been provided to demonstrate and debug the analyzers and code fixes in the IDE during development of them. After building, you should notice the analyzers producing the expected warnings in the Sample project. You can also debug the analyzers by setting a breakpoint in your analyzer and launching the `DebugRoslynAnalyzers` target of the `Lucene.Net.CodeAnalysis.Dev` project. You can also debug them by debugging the unit tests.
32+
33+
## Contributing
34+
35+
Please read and follow the [Apache Lucene.NET Contributor's Guide](https://github.com/apache/lucenenet/blob/master/CONTRIBUTING.md) first before proceeding further.
36+
37+
### Reserving a Diagnostic ID
38+
39+
Before creating any analyzers, you'll need a reserved diagnostic ID for your analyzer(s).
40+
To avoid multiple contributors attempting to use the same ID at the same time, we have created a simple process to follow.
41+
It is important that you follow this process to avoid rework of your PR.
42+
43+
1. Make sure there is an issue on the main [Apache Lucene.NET repo](https://github.com/apache/lucenenet/issues) for the analyzer(s) needed, that has been approved by the Lucene.NET team as indicated by having the `approved-rule` label.
44+
2. Reserve your diagnostic ID(s) _before_ implementing the analyzer(s):
45+
- If you are a Lucene.NET committer, you can reserve one yourself. Modify the [DiagnosticCategoryAndIdRanges.txt](DiagnosticCategoryAndIdRanges.txt) file (following the instructions in that file) to reserve your ID(s). Commit and push the change to this file directly to the `main` branch, as the only file in the commit. DO NOT include any other code or changes in this commit. In the event of a conflict, do not merge this file; discard your changes, pull latest, and try again. Include the issue number in your commit message.
46+
- If you are not a Lucene.NET committer, request in the discussion for the GitHub issue that a committer do the steps above for you for your desired number of diagnostic IDs. Please make sure to mention which category the ID(s) should belong to.
47+
3. Once you have the reserved ID(s), you can proceed with implementing your analyzer and submitting a pull request. Make sure to include your analyzer in the [AnalyzerReleases.Unshipped.md](src/Lucene.Net.CodeAnalysis.Dev/AnalyzerReleases.Unshipped.md) file.
48+
49+
### Requirements
50+
51+
Before submitting a pull request to this repo, ensure that each analyzer you're adding:
52+
1. Has a reserved ID (see above)
53+
2. Has an entry in the [AnalyzerReleases.Unshipped.md](src/Lucene.Net.CodeAnalysis.Dev/AnalyzerReleases.Unshipped.md) file, reflowing the table if needed
54+
3. Matches existing analyzer naming conventions and code styles
55+
4. Has a title, description, and message format resource in the [Resources.resx](src/Lucene.Net.CodeAnalysis.Dev/Resources.resx) file (currently English only)
56+
5. Has a working, sample violation in the `Lucene.Net.CodeAnalysis.Dev.Sample` project
57+
6. Has good unit test coverage in the `Lucene.Net.CodeAnalysis.Dev.Tests` project, using existing styles and practices per the other unit tests there
58+

0 commit comments

Comments
 (0)