Duplicate attribute errors - seem unreasonable
Answered
Suddenly Rider will underline and warn me of errors every time I "duplicate" attributes, even when those attributes are commonly duplicated. They don't cause build errors, only an annoying red underline that makes real problems difficult to find.
Here are a couple of examples of code that produce the errors:
[Theory]
[InlineData(1)] // "Duplicate 'InlineDataAttribute' attribute"
[InlineData(2)] // "Duplicate 'InlineDataAttribute' attribute"
public void Test(int input)
{
// ...
}
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)] // "Duplicate 'ProducesResponseTypeAttribute' attribute"
[ProducesResponseType(StatusCodes.Status401Unauthorized)] // "Duplicate 'ProducesResponseTypeAttribute' attribute"
public IActionResult MyAction()
{
// ...
}
How can I stop rider from showing these as errors? I realize I can ignore them from the Errors In Solution menu, but that doesn't stop the underlining.
Please sign in to leave a comment.
Hello Mfish0005,
It looks like another problem, as it causes build errors. Please check if you can build you project via `dotnet build` in terminal with the same MSBuild version that is selected in Rider settings: `File | Settings | Build, Execution, Deployment | Toolset and Build`.
Just for information. This happens again after update Rider from 2020.3.3 to 2020.3.4. But can be solved for me if invalidate caches.
' File | Invalidate Caches / Restart ... '
Happened to me on 2021.3 EAP 9 after changing there target .net version of a project.
@...'s fix above worked for me (File | Invalidate Caches / Restart ...).