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.

SA1516 doesn't report missing blank line after file scoped namespace

See original GitHub issue

This code:

namespace MyNamespace;
public class MyClass
{
}

doesn’t show SA1516 and SA1513 cannot workaround it.

I would expect that SA1516 is reported for public class MyClass like it is for namespace MyNamespace; here:

using System;
namespace MyNamespace;

Tested with StyleCop.Analyzers 1.2.0-beta.435.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
martynas1266commented, Aug 30, 2022

Any plans to merge PR and close this issue? We are using file-scoped namespaces in our project and it would be nice to enforce this rule.

1reaction
guillemuranocommented, May 30, 2023

@guillemurano SA1402 was updated to handle this last year. It was included in 1.2.0-beta.406. What version are you using?

Excellent, I was on the latest version, works fine with the prerelease

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSC : warning SA1516: Elements should be separated by ...
I've encountered this problem today aswell. Explicitly adding namespace, class and Main method to Program class helped to solve this.
Read more >
SA1516 inconsistency with classic StyleCop when ...
If I separate it with blank line StyleCop Analyzers does not report issues.
Read more >
StyleCopAnalyzers/documentation/SA1516.md at master
Cause. Adjacent C# elements are not separated by a blank line. The behavior of this rule can change based on the configuration of...
Read more >
Exploring the Usage of Neural Networks for Repairing ...
To do so, the state-of-the-art of static analysis NuGet packages is examined and further used to generate a dataset with diagnostics and.
Read more >
StyleCop Rules Documentation
The StyleCop tool provides warnings that indicate style and consistency rule violations in C# code. By default, the tool integrates into Visual Studio...
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