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

Allow porting Docs comments to Triple Slash in source #23

Merged
merged 67 commits into from
Jan 29, 2021

Conversation

carlossanlop
Copy link
Member

The Libraries team wants to make triple slash comments the source of truth to simplify the documentation efforts from developers. In order to get there, we first need to bring back all the documentation we have in MS Docs into source code.

This change adds new logic that allows copying documentation contents from dotnet-api-docs xml files back into the triple slash comments trivia section of public APIs in C# code, on an assembly by assembly basis.

This is the first successful attempt.

Pending:

  • Add unit tests.
  • Add documentation for new APIs.
  • Update the readme.

Future (nice to have):

  • Wrap existing triple slash comments information in a class, to simplify the process of overwriting. There may be some rare cases where the docs in dotnet-api-docs are empty (To be added.) but there is valid documentation in triple slash, and we want to make sure it gets preserved. It's rare since we have already manually ported our /// documentation to dotnet-api-docs in previous efforts.

@carlossanlop
Copy link
Member Author

cc @pgovind @jeffhandley @safern in case you want to take a look.

return;
}

Compilation? compilation = project.GetCompilationAsync().Result;
Copy link
Member

Choose a reason for hiding this comment

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

We still need to figure out how to get all compilations so that we get all the locations of an API for the cases where there is no an OS agnostic file for that API. Anyway, that could be done when we hit that scenario.

Fix nullability warnings.
Obtain all projects related to all relevant symbols.
Add the Nuget.Frameworks package to the Tests project so that the underlying csproj consumes it without failure.
Support event, field and delegate.
Remove boilerplate message.
Avoid adding ## Remarks.
Fix bug preventing exception comments from being added.
Fix nullability warnings.
Obtain all projects related to all relevant symbols.
… converted to see crefs.

Detect primitive types in see crefs and convert them to their simplified representation.
Add unit tests to verify this.
@carlossanlop
Copy link
Member Author

carlossanlop commented Jan 29, 2021

This PR is covering enough cases that I think I can merge it. I added a GitHub CI action to run the unit tests and they are passing now.

Pending tasks for the next PR:

  • We still need to figure out how to get all compilations so that we get all the locations of an API for the cases where there is no an OS agnostic file for that API. Anyway, that could be done when we hit that scenario.

  • Use Roslyn API to tell if a token is a reserved keyword. There are a bunch of static APIs there to tell you facts about the tokens.

  • Automatically add the <GenerateDocumentationFile> set to true in the csproj after porting docs. Use the info provided in the email with the Roslyn team.

  • Investigate how to manually run a roslyn analyzer in the source code. For example, IDE0001 needs to be executed very often after porting comments, to remove unnecessary name qualification if its namespace is already being imported among the using directives.

  • Maybe compile the assembly after the port, to determine if there are any errors warnings to address, right then and there.

  • Make sure the tool is generic enough so it can be used not only in the runtime repo, but also in WPF/WinForms/etc.

  • Update the readme file in this repo.

  • Add documentation for the new APIs in this tool.

  • Nice to have: Wrap triple slash comments in a class. It would simplify and make conversion even more clear.

@carlossanlop carlossanlop merged commit 5794617 into master Jan 29, 2021
@carlossanlop carlossanlop deleted the TripleSlashRoslyn branch January 29, 2021 16:44
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