0

I am currently facing a scenario where I have an .editorconfig file in the root directory with

[{*Test.cs,*Tests.cs}]
dotnet_diagnostic.CA1707.severity = none

This rule should disable the warning (and auto refactoring) from changing a test name from something like this: GetBusinesses_NoFilter_GetAll to this: GetBusinessesNoFilterGetAll in a file such as 'BusinessControllerTests.cs'. The problem is that this rule is being ignored from this location.

The thing is, when I also put the same rule in the project directory instead of root, the warning is no longer there. I also commented out the rules after that one to make sure that nothing is overriding, no dice.

I checked the .csproj, and .sln files and there seem to be no indication of anything overriding this rule.

Can anyone please let me know what might be causing this issue? As I wish to have one global solution rather than having separate .editorconfig files. If there's any more information that is required, please let me know and I will update.

EDIT: It seems that other test projects within the solution does not have an issue. I compared them with the new one and everything seems the same. Properties, .csproj, and structure are all the same

7
  • Is the file named .editorconfig - or editorconfig? Your post so-far doesn't show you using the leading dot . - which is required. Also, try using just [*.cs] as the file-pattern. Commented Nov 15, 2024 at 10:14
  • @Dai Yes I am adding the leading dot. I will update my post to make this clearer, but thanks for highlighting. Sadly using [*.cs] (and even [*.{cs}]) did not work. Although I have to note that using the original [{*Test.cs,*Tests.cs}] worked when placing the .editorconfig in the project Commented Nov 15, 2024 at 10:43
  • What is the root directory? Commented Nov 15, 2024 at 10:43
  • @shingo The root directory is where the .sln project lies. This is where we usually put the .editorconfig file and it has worked for the rest of the rules Commented Nov 15, 2024 at 10:45
  • How are you specifying how analyzers run in your project? (e.g. are you relying on the .NET SDK to import them implicitly, or are you using explicit NuGet references? What MSBuild properties for analysis are you using? And which SDK version are you using? Are the messages suppressed if you do a command-line build using msbuild (i.e. does it only affect Visual Studio-based builds?). What if you run the "Analyze" main-menu option? Commented Nov 15, 2024 at 10:51

1 Answer 1

0

I simply created a project and created a .editorconfig file in the root directory. I tried to reproduce the problem you encountered, but failed. Whether using [{*Test.cs,*Tests.cs}] or [*.cs] or [*.{cs}], the dotnet_diagnostic.CA1707.severity = none rule can be successfully applied.

In fact, you can avoid adding it manually, as shown in the following picture. When you have a CA1707 warning, you only need to click the yellow light bulb and it will be automatically added according to this setting: enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.