Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix analyzer [RCS1246](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1246) ([PR](https://github.com/dotnet/roslynator/pull/1676))
- Fix analyzer [RCS1248](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1248) ([PR](https://github.com/dotnet/roslynator/pull/1677))
- Fix analyzer [RCS1203](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1203) ([PR](https://github.com/dotnet/roslynator/pull/1683))
- Fix analyzer [RCS1043](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1043) ([PR](https://github.com/dotnet/roslynator/pull/1684))
- Fix refactoring [Check expression for null](https://josefpihrt.github.io/docs/roslynator/refactorings/RR0024) ([PR](https://github.com/dotnet/roslynator/pull/1682))

## [4.14.0] - 2025-07-26
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ private static void AnalyzeTypeDeclaration(SyntaxNodeAnalysisContext context)
if (_metadataNames.Any(c => symbol.InheritsFrom(c)))
return;

foreach (ISymbol member in symbol.GetMembers())
{
if (member.HasAttribute(MetadataNames.System_Text_RegularExpressions_GeneratedRegexAttribute))
return;
}

foreach (MemberDeclarationSyntax member in typeDeclaration.Members)
{
if (member is MethodDeclarationSyntax methodDeclaration
Expand Down
1 change: 1 addition & 0 deletions src/Core/MetadataNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ internal static class MetadataNames
public static readonly MetadataName System_Runtime_Serialization_StreamingContext = MetadataName.Parse("System.Runtime.Serialization.StreamingContext");
public static readonly MetadataName System_Span_T = MetadataName.Parse("System.Span`1");
public static readonly MetadataName System_StringComparison = MetadataName.Parse("System.StringComparison");
public static readonly MetadataName System_Text_RegularExpressions_GeneratedRegexAttribute = MetadataName.Parse("System.Text.RegularExpressions.GeneratedRegexAttribute");
public static readonly MetadataName System_Text_RegularExpressions_Regex = MetadataName.Parse("System.Text.RegularExpressions.Regex");
public static readonly MetadataName System_Text_RegularExpressions_RegexOptions = MetadataName.Parse("System.Text.RegularExpressions.RegexOptions");
public static readonly MetadataName System_Text_StringBuilder = MetadataName.Parse("System.Text.StringBuilder");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,18 @@ class FrameworkElement
}
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.RemovePartialModifierFromTypeWithSinglePart)]
public async Task TestNoDiagnostic_GeneratedRegexAttribute()
{
await VerifyNoDiagnosticAsync("""
using System.Text.RegularExpressions;

partial class C
{
[GeneratedRegex("^[a-z]{2}$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)]
private static partial Regex Pattern();
}
""", options: Options.AddAllowedCompilerDiagnosticId("CS8795"));
}
}
Loading