You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SA1516 doesn't report missing blank line after file scoped namespace #3512
/// Paginated Reports
///
public class PaginatedReports
{
///
/// Total
///
public int Total { get; set; }
/// <summary>
/// Page
/// </summary>
public int Page { get; set; }
/// <summary>
/// Page Size
/// </summary>
public int PageSize { get; set; }
/// <summary>
/// Items
/// </summary>
public List<ReportItem> Items { get; set; } = new();
}
/// <summary>
/// My Test
/// </summary>
public class MyTest
{
/// <summary>
/// Abc
/// </summary>
public int Abc { get; set; }
}
}
`
But when I stick to scoped namespace it's not shown
`
namespace EamReportingMicroservice.Core.Models;
///
/// Paginated Reports
///
public class PaginatedReports
{
///
/// Total
///
public int Total { get; set; }
/// <summary>
/// Page
/// </summary>
public int Page { get; set; }
/// <summary>
/// Page Size
/// </summary>
public int PageSize { get; set; }
/// <summary>
/// Items
/// </summary>
public List<ReportItem> Items { get; set; } = new();
}
///
/// My Test
///
public class MyTest
{
///
/// Abc
///
public int Abc { get; set; }
}
`
This is the ruleset I'm using:
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.MaintainabilityRules"> <Rule Id="SA1119" Action="Warning" /> <!-- Statement should not use unnecessary parenthesis --> <Rule Id="SA1400" Action="Warning" /> <!-- Access modifier should be declared --> <Rule Id="SA1401" Action="Warning" /> <!-- Fields should be private --> <Rule Id="SA1402" Action="Warning" /> <!-- File may only contain a single type --> <Rule Id="SA1403" Action="Warning" /> <!-- File may only contain a single namespace --> <Rule Id="SA1404" Action="Warning" />
Activity
martynas1266 commentedon 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.
ldeluigi commentedon Feb 25, 2023
Us too
prlcutting commentedon Mar 10, 2023
Ditto.
symbiogenesis commentedon May 4, 2023
bump
guillemurano commentedon May 30, 2023
I have the same issue with SA1402 with scoped namespace
bjornhellander commentedon May 30, 2023
@guillemurano I don't see any strange behaviour with SA1402. Could you describe the problem you are having?
guillemurano commentedon May 30, 2023
I'm getting the correct SA1402 with this code
`
namespace EamReportingMicroservice.Core.Models
{
///
/// Paginated Reports
///
public class PaginatedReports
{
///
/// Total
///
public int Total { get; set; }
}
}
`
But when I stick to scoped namespace it's not shown
`
namespace EamReportingMicroservice.Core.Models;
///
/// Paginated Reports
///
public class PaginatedReports
{
///
/// Total
///
public int Total { get; set; }
}
///
/// My Test
///
public class MyTest
{
///
/// Abc
///
public int Abc { get; set; }
}
`
This is the ruleset I'm using:
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers.MaintainabilityRules"> <Rule Id="SA1119" Action="Warning" /> <!-- Statement should not use unnecessary parenthesis --> <Rule Id="SA1400" Action="Warning" /> <!-- Access modifier should be declared --> <Rule Id="SA1401" Action="Warning" /> <!-- Fields should be private --> <Rule Id="SA1402" Action="Warning" /> <!-- File may only contain a single type --> <Rule Id="SA1403" Action="Warning" /> <!-- File may only contain a single namespace --> <Rule Id="SA1404" Action="Warning" />bjornhellander commentedon 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?
guillemurano commentedon May 30, 2023
Excellent, I was on the latest version, works fine with the prerelease