Suppress warning in Rider for a specific project

856 views Asked by At

I am working on a project that only contains Models and I have a lot of properties like this one:

public string FromReversed
{
    get
    {
        return From.ReverseString();
    }
    #if MyDirective
    [Obsolte("Only in here because if the setter is not included the this property will not be saved into mongoDB")
    set { }
    #endif
}

When using the Rider IDE I get this warning: 'value' parameter is not used I can disable that warning by placing this comment // ReSharper disable once ValueParameterNotUsed on top of that property or by placing this comment // ReSharper disable ValueParameterNotUsed at the top of my file. Now my question is how can I disable that warning for the entire project?

I have attempted these 4 things with no success:

  1. If I do '.' + Enter and then change the severity of that warning from warning to 'Do not show': enter image description here Doing so makes the warning go away but I want that warning to also appear in other projects. I just want to ignore that warning for this specific project withtout having to go to every file and place // ReSharper disable ValueParameterNotUsed.

  2. I have tried placing this attributes on my GlobalUsing.cs file:

global using Swashbuckle.AspNetCore.Annotations;
global using JetBrains.Annotations;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

// This works if I place this attribute on top of the class
[assembly: SuppressMessage("ReSharper", "ValueParameterNotUsed")]
  1. I tried placing resharper_value_parameter_not_used=none line on .editorconfig based on this article https://dunnhq.com/posts/2020/codeinspections/. But I am probably naming the property incorrectly.

  2. I have tried placing the id of that warning because it contains no number on the tag of my .csproj file like so:

<PropertyGroup>
  <NoWarn>1701;1702;ValueParameterNotUsed</NoWarn>
</PropertyGroup>
2

There are 2 answers

0
Tono Nam On BEST ANSWER

This file contains the global settings for Rider in Windows 11: %UserProfile%\AppData\Roaming\JetBrains\Rider<Version>\GlobalSettings.DotSettings

I noticied that when I changed the inspection severity like this:

enter image description here]

Then this line was added to my GlobalSettings.DotSettings file

<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedAutoPropertyAccessor_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>

The solution was to move that configuration from GlobalSettings.DotSettings file to MyProject.csproj.DotSettings. And now those changes only affect the specific project that I want.

3
jhmckimm On

You could perhaps use an AssemblyAttrubute definition in your .csproj to achieve this:

<ItemGroup>
  <AssemblyAttribute Include="System.Diagnostics.CodeAnalysis.SuppressMessageAttribute">
    <_Parameter1>ReSharper</_Parameter1>
    <_Parameter2>ValueParameterNotUsed</_Parameter2>
  </AssemblyAttribute>
</ItemGroup>