question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SA1402 does not take topLevelType setting into account for records

See original GitHub issue

1.2.0-beta.507

In our stylecop json we have:

"maintainabilityRules": {
   "topLevelTypes": [ "class" ]
}

But still it warns about files containing more than one record. It’s fine if the default for topLevelTypes has changed to include records but not being able to configure it at all is inconvenient.

Issue Analytics

  • State:open
  • Created 3 months ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
appel1commented, Jun 27, 2023

@sharwell We opted to disable SA1402 and create our own that only requires class and struct to be in separate files instead of hundreds of #pragmas. If you change your mind in the future we can just revert that change.

0reactions
lennartb-commented, Jul 5, 2023

Yeah, more configuration options would have been great. We have many command handler classes which include the commands as records with 1- 3 members (i.e. one-liners), adding a suppression to each file is not nice. I guess we’ll disable SA1402 for these particular folders in .editorconfig.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SA1402 does not fire for record classes · Issue #3542
Expected behavior: SA1402 is reported for record classes, same as for non-record classes. C# version: 10.0 StyleCopAnalyzers: 1.2.0-beta.406, ...
Read more >
StyleCop SA1402 and Generics
I think SA1402 is a great rule but I have problem with generics. I've got a class that uses the Func delegate, so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found