-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CodeAnalysis module and docs recipe now supports extension methods, #342
- Loading branch information
1 parent
e0f0874
commit bba21b0
Showing
9 changed files
with
158 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
themes/Docs/Samson/Shared/Section/_ExtensionMethods.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@using Microsoft.AspNetCore.Html; | ||
@using Microsoft.CodeAnalysis; | ||
@{ | ||
ITypeSymbol modelSymbol = Model.Get<ITypeSymbol>("Symbol"); | ||
IList<IDocument> methods = Model.List<IDocument>("ExtensionMethods") | ||
?.Where(x => x.Get<bool>("IsResult")) | ||
.OrderBy(x => x["DisplayName"]) | ||
.ToList(); | ||
if(methods.Count > 0) | ||
{ | ||
<text> | ||
<h1 id="ExtensionMethods">Extension Methods</h1> | ||
<div class="box"> | ||
<div class="box-body no-padding"> | ||
<table class="table table-striped table-hover three-cols"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Value</th> | ||
<th>Summary</th> | ||
</tr> | ||
</thead> | ||
@foreach(IDocument method in methods) | ||
{ | ||
ISymbol reducedSymbol = method.Get<IMethodSymbol>("Symbol")?.ReduceExtensionMethod(modelSymbol); | ||
string reducedName = reducedSymbol?.ToDisplayString(new SymbolDisplayFormat( | ||
typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes, | ||
genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, | ||
parameterOptions: SymbolDisplayParameterOptions.IncludeType, | ||
memberOptions: SymbolDisplayMemberOptions.IncludeParameters, | ||
miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes)); | ||
IDocument returnType = method.Get<IDocument>("ReturnType"); | ||
<tr> | ||
<td>@Context.GetTypeLink(method, reducedName)</td> | ||
<td>@(returnType == null ? new HtmlString(string.Empty) : Context.GetTypeLink(returnType))</td> | ||
<td> | ||
<div>@Html.Raw(method["Summary"])</div> | ||
@{ | ||
IDocument containingType = method.Document(CodeAnalysisKeys.ContainingType); | ||
<div><small><em>From @Context.GetTypeLink(containingType)</em></small></div> | ||
} | ||
</td> | ||
</tr> | ||
} | ||
</table> | ||
</div> | ||
</div> | ||
</text> | ||
} | ||
} |