Summary
We have a vendored 1273-line src/Shared/JetBrainsAnnotations.cs containing dozens of ASP.NET MVC, Razor, XAML, and WPF attributes that this codebase will never use. Actual usage is narrow — we should evaluate migrating to built-in .NET equivalents and removing the vendored file.
Current usage
| Attribute |
Used in |
Modern .NET replacement |
[NotNull] |
Check.cs |
NRT (already enabled) handles this |
[ContractAnnotation("=> halt")] |
Check.cs, one extension method |
[DoesNotReturn] from System.Diagnostics.CodeAnalysis |
[InvokerParameterName] |
Check.cs |
[CallerArgumentExpression] |
[NoEnumeration] |
Check.cs |
No direct replacement (can drop — generic constraint achieves the same) |
[UsedImplicitly] |
~20 syntax extension classes |
SuppressMessage or remove if public API |
[PublicAPI] |
Generated accessors |
Public members don't need unused-member suppression |
What to do
- Audit all usages of JetBrains.Annotations attributes across the codebase
- Migrate each usage to the
System.Diagnostics.CodeAnalysis equivalent where one exists
- For
[UsedImplicitly] / [PublicAPI], evaluate whether suppression is still needed
- Delete
src/Shared/JetBrainsAnnotations.cs
- Remove the
JetBrains.Annotations mandatory import from GraphZen.sln.DotSettings and the global using from src/Directory.Build.props
Notes
- We already have
System.Diagnostics.CodeAnalysis as a global using
- This would eliminate 1200+ lines of dead code
- The 8 files with explicit
using JetBrains.Annotations statements would also need cleanup
Summary
We have a vendored 1273-line
src/Shared/JetBrainsAnnotations.cscontaining dozens of ASP.NET MVC, Razor, XAML, and WPF attributes that this codebase will never use. Actual usage is narrow — we should evaluate migrating to built-in .NET equivalents and removing the vendored file.Current usage
[NotNull]Check.cs[ContractAnnotation("=> halt")]Check.cs, one extension method[DoesNotReturn]fromSystem.Diagnostics.CodeAnalysis[InvokerParameterName]Check.cs[CallerArgumentExpression][NoEnumeration]Check.cs[UsedImplicitly]SuppressMessageor remove if public API[PublicAPI]What to do
System.Diagnostics.CodeAnalysisequivalent where one exists[UsedImplicitly]/[PublicAPI], evaluate whether suppression is still neededsrc/Shared/JetBrainsAnnotations.csJetBrains.Annotationsmandatory import fromGraphZen.sln.DotSettingsand the global using fromsrc/Directory.Build.propsNotes
System.Diagnostics.CodeAnalysisas a global usingusing JetBrains.Annotationsstatements would also need cleanup