Problem
CleanupStep removes several annotations using exact string replacement or whole-line classification. This is unreliable when an annotation is combined with other attributes or spans multiple lines.
A source export configured with these options can therefore retain JetBrains annotation usages even though their definitions and using directive are excluded:
- IncludeJetBrainsAnnotations=false
- IncludeJetBrainsAnnotationsUsing=false
- RemoveContractAnnotations=true
- IncludeValidatedNotNullAttribute=false
- RemoveValidatedNotNull=true
Concrete cases in the current source:
- Combined attribute lists such as [NotNull, ValidatedNotNull] are not handled by the exact [ValidatedNotNull] replacement.
- The multiline ContractAnnotation on Check.IsSameAs is classified one line at a time. Only the line beginning with [ContractAnnotation( is removed, leaving its argument and closing lines behind.
- NoEnumeration usages remain because there is no corresponding cleanup option. This can leave generated code referring to an attribute whose definition was intentionally excluded.
Consumers currently need an additional post-processing step to remove these tokens while preserving adjacent nullable-flow annotations such as NotNull and NotNullWhen.
Expected behavior
The exporter should remove configured JetBrains annotations regardless of whether they:
- occupy a standalone attribute list,
- share an attribute list with other annotations,
- appear in adjacent attribute lists, or
- span multiple lines.
Adjacent annotations that are not being removed must remain intact. Excluding JetBrains annotations should also provide a supported way to remove NoEnumeration usages.
Suggested acceptance criteria
- RemoveValidatedNotNull removes ValidatedNotNull from combined and standalone attribute lists while preserving NotNull.
- RemoveContractAnnotations removes both single-line and multiline ContractAnnotation attributes without removing neighboring attributes.
- NoEnumeration usages can be removed when JetBrains annotations are excluded.
- Cleanup tests cover combined, adjacent, and multiline attribute syntax.
- Generated output compiles without JetBrains.Annotations when its definitions and using directive are excluded.
Problem
CleanupStep removes several annotations using exact string replacement or whole-line classification. This is unreliable when an annotation is combined with other attributes or spans multiple lines.
A source export configured with these options can therefore retain JetBrains annotation usages even though their definitions and using directive are excluded:
Concrete cases in the current source:
Consumers currently need an additional post-processing step to remove these tokens while preserving adjacent nullable-flow annotations such as NotNull and NotNullWhen.
Expected behavior
The exporter should remove configured JetBrains annotations regardless of whether they:
Adjacent annotations that are not being removed must remain intact. Excluding JetBrains annotations should also provide a supported way to remove NoEnumeration usages.
Suggested acceptance criteria