Skip to content

Revisit vendored JetBrains.Annotations — migrate to System.Diagnostics.CodeAnalysis #49

@craigsmitham

Description

@craigsmitham

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

  1. Audit all usages of JetBrains.Annotations attributes across the codebase
  2. Migrate each usage to the System.Diagnostics.CodeAnalysis equivalent where one exists
  3. For [UsedImplicitly] / [PublicAPI], evaluate whether suppression is still needed
  4. Delete src/Shared/JetBrainsAnnotations.cs
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions