-
-
Notifications
You must be signed in to change notification settings - Fork 278
Open
Description
Product and Version Used
Roslynator Version: 4.14.1
IDE: Visual Studio 2022
Framework: .NET 8.0
Description
The analyzer RCS0034 (Put type parameter constraint on its own line) reports a warning even when the constraint is placed on a new line, specifically when using C# 12 Primary Constructors.
It seems the analyzer does not account for the primary constructor parameter list appearing between the class declaration and the where clause.
Steps to Reproduce
- Create a class using C# 12 Primary Constructors with a generic type constraint.
public class MixedConstraintService<TKey, TValue>(TKey key, TValue value) where TKey : notnull where TValue : new()
{
public TKey Key { get; } = key;
public TValue Value { get; } = value;
}
- Format the code so the where clause is on its own line (as required by RCS0034).
public class MixedConstraintService<TKey, TValue>(TKey key, TValue value)
where TKey : notnull
where TValue : new()
{
public TKey Key { get; } = key;
public TValue Value { get; } = value;
}
Expected behavior
The analyzer should not report a warning because the where constraint is already on its own line.
Actual behavior
The analyzer reports: warning RCS0034: Put type parameter constraint on its own line.
The CLI tool reports: Infinite loop detected: Reported diagnostics have been previously fixed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels