[repo] Adding some guidance/requirements in CONTRIBUTING for nullable reference types and static analysis (#4284)
Co-authored-by: Cijo Thomas <cijo.thomas@gmail.com> Co-authored-by: Reiley Yang <reyang@microsoft.com>
This commit is contained in:
parent
990deee419
commit
b200ceb86e
|
|
@ -214,3 +214,42 @@ only and does not affect the actual build of the project.
|
|||
This repository also includes StyleCop ruleset files under the `./build` folder.
|
||||
These files are used to configure the _StyleCop.Analyzers_ which runs during
|
||||
build. Breaking the rules will result in a build failure.
|
||||
|
||||
## New projects
|
||||
|
||||
New projects are required to:
|
||||
|
||||
* Use [nullable reference
|
||||
types](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/nullable-reference-types).
|
||||
|
||||
This should be enabled automatically via
|
||||
[Common.props](https://github.com/open-telemetry/opentelemetry-dotnet/blob/990deee419ab4c1449efd628bed3df57a50963a6/build/Common.props#L9).
|
||||
New project MUST NOT disable this.
|
||||
|
||||
* Pass [static
|
||||
analysis](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/overview).
|
||||
|
||||
New projects MUST enable static analysis by specifying
|
||||
`<AnalysisLevel>latest-all</AnalysisLevel>` in the project file (`.csproj`).
|
||||
|
||||
> **Note**
|
||||
> There are other project-level features enabled automatically via
|
||||
[Common.props](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/build/Common.props)
|
||||
new projects must NOT manually override these settings.
|
||||
|
||||
## New code
|
||||
|
||||
New code files MUST enable [nullable reference
|
||||
types](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/nullable-reference-types)
|
||||
manually in projects where it is not automatically enabled project-wide. This is
|
||||
done by specifying `#nullable enable` towards the top of the file (usually after
|
||||
the copyright header). We are currently working towards enabling nullable
|
||||
context in every project by updating code as it is worked on, this requirement
|
||||
is to make sure the surface area of code needing updates is shrinking and not
|
||||
expanding.
|
||||
|
||||
> **Note**
|
||||
> The first time a project is updated to use nullable context in public APIs
|
||||
some housekeeping needs to be done in public API definitions (`.publicApi`
|
||||
folder). This can be done automatically via a code fix offered by the public API
|
||||
analyzer.
|
||||
|
|
|
|||
Loading…
Reference in New Issue