Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable documentation analysis for <exclude> elements #3121

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

CPAM34
Copy link

@CPAM34 CPAM34 commented Mar 3, 2020

I have a fix for issue #3094 as reported in the main repository, concerning the exclusion of rule enforcement for Doc rules when <exclude/> is present. I have created accompanying new unit tests in the StyleCop.Analyzers.Test project, all of which have passed.

Comment on lines 61 to 66
// This documentation rule is excluded via the <exclude /> tag
/*if (completeDocumentation.Nodes().OfType<XElement>().Any(element => element.Name == XmlCommentHelper.ExcludeXmlTag))
{
return;
}*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More commented code

Comment on lines 210 to 213
/*if (fileHeader.GetElement("exclude") != null)
{
return;
}*/
Copy link

@RobSiklos RobSiklos Mar 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why commented? Anyway, you don't need to modify this code. The "file header" is not true XML documentation, and can't have an "exclude" tag. See https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md

Comment on lines 99 to 104
/*if (completeDocumentation.Nodes().OfType<XElement>().Any(element => element.Name == XmlCommentHelper.ExcludeXmlTag))
{
return;
}*/

// var hasExcludeTag = completeDocumentation.Nodes().OfType<XElement>().Any(element => element.Name == XmlCommentHelper.ExcludeXmlTag);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's up with this commented code?

@codecov
Copy link

codecov bot commented Mar 4, 2020

Codecov Report

Merging #3121 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #3121      +/-   ##
==========================================
- Coverage   97.13%   97.10%   -0.03%     
==========================================
  Files         828      828              
  Lines      103971   104551     +580     
  Branches     3354     3389      +35     
==========================================
+ Hits       100991   101524     +533     
- Misses       2090     2136      +46     
- Partials      890      891       +1     

public class ClassName
{
/// <exclude/>
public void Test() { }
Copy link
Member

@sharwell sharwell Dec 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ Should we also disable checks for a member if the containing type is marked with <exclude/>?

📝 The test for this could be added without duplicating all of the current tests, by having a single class with several members.

/// <exclude/>
public class ClassName
{
     public void ClassName() { }
     ~ClassName() { }
     public int Property { get; set; }
     public void Test() { }
     // ...
}

@sharwell sharwell changed the title Fix for reported Issue 3094 Disable documentation analysis for elements marked with <exclude> Dec 30, 2020
@sharwell sharwell changed the title Disable documentation analysis for elements marked with <exclude> Disable documentation analysis for <exclude> elements Dec 30, 2020
public async Task TestTypeWithExcludedDocumentationAsync(string typeName)
{
var testCode = @"
/// <exclude/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 It seems like the <exclude/> element shouldn't always exclude the element, but rather it should force a public element to be treated like a non-public element. If documentation is required for non-public elements, diagnostics should still be reported for missing documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants