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

feat: view source for assemblies using sourcelink #8548

Merged
merged 2 commits into from
Mar 25, 2023
Merged

Conversation

yufeih
Copy link
Contributor

@yufeih yufeih commented Mar 25, 2023

Computes source URL of a symbol using source link: When an assembly is built with source link enabled, and a PDB file exists next to the assembly, docfx computes the source URL for "view source" and cross reference of a symbol using the source link info in the PDB file.

PDBs usually exist for the entry assemblies, so "view source" typically works. But PDB files are usually missing for NuGet dependencies, so cross referencing rarely works unless we have NuGet/Home#9667

#8567

@yufeih yufeih added the new-feature Makes the pull request to appear in "New Features" section of the next release note label Mar 25, 2023
@codecov
Copy link

codecov bot commented Mar 25, 2023

Codecov Report

Patch coverage: 68.96% and project coverage change: -0.04 ⚠️

Comparison is base (52e3455) 75.22% compared to head (bf47810) 75.18%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8548      +/-   ##
==========================================
- Coverage   75.22%   75.18%   -0.04%     
==========================================
  Files         645      649       +4     
  Lines       23637    23837     +200     
==========================================
+ Hits        17782    17923     +141     
- Misses       5855     5914      +59     
Impacted Files Coverage Δ
...de.Dotnet/SourceLink/SymbolSourceDocumentFinder.cs 36.11% <36.11%> (ø)
...crosoft.DocAsCode.Dotnet/Visitors/VisitorHelper.cs 89.77% <66.66%> (-1.34%) ⬇️
...osoft.DocAsCode.Dotnet/SourceLink/SourceLinkMap.cs 71.83% <71.83%> (ø)
src/Microsoft.DocAsCode.Common/Git/GitUtility.cs 81.56% <85.71%> (+6.56%) ⬆️
...t.DocAsCode.Dotnet/SymbolUrlResolver.SourceLink.cs 92.15% <92.15%> (ø)
...de.Dotnet/ExtractMetadata/ExtractMetadataWorker.cs 75.47% <100.00%> (ø)
....Dotnet/SourceLink/PortableCustomDebugInfoKinds.cs 100.00% <100.00%> (ø)
src/Microsoft.DocAsCode.Dotnet/SymbolFormatter.cs 100.00% <100.00%> (ø)
src/Microsoft.DocAsCode.Dotnet/SymbolHelper.cs 96.96% <100.00%> (ø)
...rc/Microsoft.DocAsCode.Dotnet/SymbolUrlResolver.cs 100.00% <100.00%> (ø)
... and 2 more

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@yufeih yufeih marked this pull request as ready for review March 25, 2023 03:23
@yufeih yufeih closed this Mar 25, 2023
@yufeih yufeih reopened this Mar 25, 2023
@yufeih yufeih merged commit 7b5036b into main Mar 25, 2023
@yufeih yufeih deleted the symbolurl-sourcelink branch March 25, 2023 06:46
Comment on lines +77 to +81
// GitHub
return Regex.Replace(
rawUrl,
@"^https://raw\.githubusercontent\.com/([^/]+)/([^/]+)/([^/]+)/(.+)$",
string.IsNullOrEmpty(branch) ? "https://github.com/$1/$2/blob/$3/$4" : $"https://github.com/$1/$2/blob/{branch}/$4");

Choose a reason for hiding this comment

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

Can this be customised to support hosting services other than GitHub, by adding JavaScript code to the theme or template? Like the "Improve this Doc" link can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a valid ask. I need some time to think through the extensibility model to see where this fits so it is not included in the first place. The template JavaScript isn't always the best way of customization and today's template extensibility requires a lot of copy n paste and is error prone. I hated it when forking the modern template and having to support a combination of default/modern/statictoc/memberpage templates.

The other approach is to expose a set of regex-based configs for mutate git URLs.

Comment on lines +109 to +119
public void Dispose()
{
GC.SuppressFinalize(this);
_peReader.Dispose();
_pdbReaderProvider.Dispose();
}

~SourceLinkProvider()
{
Dispose();
}

Choose a reason for hiding this comment

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

A finalizer generally should not call Dispose() on other objects. If those own unmanaged resources, they should have their own finalizers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature Makes the pull request to appear in "New Features" section of the next release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants