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

c# region support for code snippets broken by #endregion with extra text #1200

Closed
tobiasbunyan opened this Issue Jan 18, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@tobiasbunyan

tobiasbunyan commented Jan 18, 2017

Title

The regex for detecting #endregion in c# code snippet support expects to only have whitespace to the end of the line after #endregion. If there is extra text the #endregion is not detected, resulting in an error.

Functional impact

Documentation build fails.

Minimal repro steps

  1. Create a class with text after the endregion:
#region TestRegion
public class someclass
{
}
#endregion TestRegion
  1. Reference this file in a conceptual document using a code snippet markdown:
[!code-csharp[Main](someclass.cs?name=TestRegion)]
  1. Build the documentation

Expected result

The code snippet is generated as normal.

Actual result

Error occurs and build fails.

Document.CompilePhaseHandler.ConceptualDocumentProcessor.Build.BuildConceptualDocument](articles/intro.md)Tag name TestRegion is not found Web.Documentation C:\Users\tbunyan\Source\Workspaces\Web.Documentation\EXEC

Further technical details

Whilst adding text after an #endregion has no effect, it is not actually prohibited, and so should be allowed for.

Changing the CSharpCodeSnippetCommentEndLineRegex value in Microsoft.DocAsCode.Dfm.TagNameBlockPathQueryOption should alleviate this.

Untested suggestion:
From

@"^\s*#\s*endregion\s*$"

To

@"^\s*#\s*endregion\s?.*$"
@vwxyzh

This comment has been minimized.

Show comment
Hide comment
@vwxyzh

vwxyzh Feb 20, 2017

Contributor

@tobiasbunyan This bug should be fixed in current release version.

Contributor

vwxyzh commented Feb 20, 2017

@tobiasbunyan This bug should be fixed in current release version.

@chenkennt chenkennt closed this Apr 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment