Skip to content

Commit

Permalink
Merge 2fbe4ef into c968e07
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeih authored Apr 12, 2023
2 parents c968e07 + 2fbe4ef commit 116a626
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/Microsoft.DocAsCode.Dotnet/CompilationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ internal static class CompilationHelper
{
CS.SyntaxFactory.ParseSyntaxTree(
"""
class Bootstrap
{
public static void Main(string[] foo) { }
}
"""),
class Bootstrap
{
public static void Main(string[] foo) { }
}
"""),
};

public static bool CheckDiagnostics(this Compilation compilation, bool errorAsWarning)
Expand Down Expand Up @@ -56,13 +56,13 @@ public static bool CheckDiagnostics(this Compilation compilation, bool errorAsWa
public static Compilation CreateCompilationFromCSharpFiles(IEnumerable<string> files)
{
return CS.CSharpCompilation.Create(
assemblyName: "cs.temp.dll",
assemblyName: null,
options: new CS.CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, xmlReferenceResolver: XmlFileResolver.Default),
syntaxTrees: files.Select(path => CS.SyntaxFactory.ParseSyntaxTree(File.ReadAllText(path), path: path)),
references: GetDefaultMetadataReferences("C#"));
}

public static Compilation CreateCompilationFromCSharpCode(string code, string name = "cs.temp.dll", params MetadataReference[] references)
public static Compilation CreateCompilationFromCSharpCode(string code, string name = null, params MetadataReference[] references)
{
return CS.CSharpCompilation.Create(
name,
Expand All @@ -74,13 +74,13 @@ public static Compilation CreateCompilationFromCSharpCode(string code, string na
public static Compilation CreateCompilationFromVBFiles(IEnumerable<string> files)
{
return VB.VisualBasicCompilation.Create(
assemblyName: "vb.temp.dll",
assemblyName: null,
options: new VB.VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, globalImports: GetVBGlobalImports(), xmlReferenceResolver: XmlFileResolver.Default),
syntaxTrees: files.Select(path => VB.SyntaxFactory.ParseSyntaxTree(File.ReadAllText(path), path: path)),
references: GetDefaultMetadataReferences("VB"));
}

public static Compilation CreateCompilationFromVBCode(string code, string name = "vb.temp.dll", params MetadataReference[] references)
public static Compilation CreateCompilationFromVBCode(string code, string name = null, params MetadataReference[] references)
{
return VB.VisualBasicCompilation.Create(
name,
Expand All @@ -93,7 +93,7 @@ public static (Compilation, IAssemblySymbol) CreateCompilationFromAssembly(strin
{
var metadataReference = CreateMetadataReference(assemblyPath);
var compilation = CS.CSharpCompilation.Create(
"EmptyProjectWithAssembly",
assemblyName: null,
options: new CS.CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary),
syntaxTrees: s_assemblyBootstrap,
references: GetReferenceAssemblies(assemblyPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public override MetadataItem DefaultVisit(ISymbol symbol)
item.DisplayQualifiedNames = new SortedList<SyntaxLanguage, string>();
item.Source = VisitorHelper.GetSourceDetail(symbol, _compilation);
var assemblyName = symbol.ContainingAssembly?.Name;
item.AssemblyNameList = string.IsNullOrEmpty(assemblyName) ? null : new List<string> { assemblyName };
item.AssemblyNameList = string.IsNullOrEmpty(assemblyName) || assemblyName is "?" ? null : new List<string> { assemblyName };
if (symbol is not INamespaceSymbol)
{
var namespaceName = VisitorHelper.GetId(symbol.ContainingNamespace);
Expand Down
2 changes: 1 addition & 1 deletion templates/modern/partials/class.header.tmpl.partial
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<div class="facts text-secondary">
<dl><dt>{{__global.namespace}}</dt><dd>{{{namespace.specName.0.value}}}</dd></dl>
<dl><dt>{{__global.assembly}}</dt><dd>{{assemblies.0}}.dll</dd></dl>
{{#assemblies.0}}<dl><dt>{{__global.assembly}}</dt><dd>{{assemblies.0}}.dll</dd></dl>{{/assemblies.0}}
</div>

<div class="markdown summary">{{{summary}}}</div>
Expand Down

0 comments on commit 116a626

Please sign in to comment.