Skip to content

Commit d1faeb2

Browse files
committed
Fix assembly load problem, fix some warnings, and cleanup build
1 parent 432d25a commit d1faeb2

18 files changed

+133
-100
lines changed

azure-pipelines.yml

+19-55
Original file line numberDiff line numberDiff line change
@@ -78,67 +78,24 @@ jobs:
7878
displayName: Clone All Repositories
7979
inputs:
8080
solution: build.proj
81-
msbuildArgs: /t:Clone /v:q /bl:$(Build.ArtifactStagingDirectory)/logs/clone.binlog
81+
msbuildArgs: /t:Clone /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/clone.binlog
8282
msbuildArchitecture: x64
8383
env:
8484
source-dot-net-stage1-blob-container-url: $(source-dot-net-stage1-blob-container-url)
8585

86-
- powershell: |
87-
Stop-Process -Name "dotnet"
88-
$installScript = Join-Path $env:TEMP dotnet-install.ps1
89-
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
90-
Invoke-WebRequest https://dot.net/v1/dotnet-install.ps1 -UseBasicParsing -OutFile $installScript
91-
92-
$installDir = "$(Agent.ToolsDirectory)/dotnet"
93-
94-
ls -Recurse -Include global.json | %{
95-
try {
96-
Write-Host "Processing $_"
97-
$v = $_ | Get-Content -Raw | ConvertFrom-Json | %{ if ($_.tools.dotnet) {$_.tools.dotnet} else {$_.sdk.version} }
98-
if (-not $v)
99-
{
100-
Write-Host "No version found in $_"
101-
return
102-
}
103-
$isSensibleVersion = $v.Split('.')[0] -as [int] -le 30
104-
if (-not $isSensibleVersion)
105-
{
106-
Write-Host "Skipping bogus version $v"
107-
return
108-
}
109-
110-
Write-Host "Installing .NET CLI version $v"
111-
try
112-
{
113-
& $installScript -Version $v -InstallDir $installDir -NoPath
114-
}
115-
catch
116-
{
117-
try
118-
{
119-
& $installScript -Version $v -InstallDir $installDir -NoPath -AzureFeed https://dotnetbuilds.azureedge.net/public
120-
}
121-
catch
122-
{
123-
throw "Unable to install Version $v"
124-
}
125-
}
126-
}
127-
catch
128-
{
129-
Write-Host "Skipping bad json file."
130-
}
131-
}
132-
displayName: 'Install Required Versions of .NET Core'
86+
- task: VSBuild@1
87+
displayName: Prepare All Repositories
88+
inputs:
89+
solution: build.proj
90+
msbuildArgs: /t:Prepare /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/prepare.binlog
91+
msbuildArchitecture: x64
13392

13493
- task: VSBuild@1
13594
displayName: Build source index
13695
inputs:
13796
solution: build.proj
138-
msbuildArgs: /t:Build /v:q /bl:$(Build.ArtifactStagingDirectory)/logs/build.binlog
97+
msbuildArgs: /t:BuildIndex /v:n /bl:$(Build.ArtifactStagingDirectory)/logs/build.binlog
13998
msbuildArchitecture: x64
140-
env:
141-
source-dot-net-stage1-blob-container-url: $(source-dot-net-stage1-blob-container-url)
14299

143100
- powershell: |
144101
deployment/install-tool.ps1 -Name 'azure-cli' -Version 2.8.0 -TestPath '/wbin/az.cmd' -BinPath '/wbin/'
@@ -209,11 +166,18 @@ jobs:
209166
inlineScript: >
210167
az webapp restart --name netsourceindex --slot staging --resource-group source.dot.net
211168
212-
- powershell: |
169+
- pwsh: |
213170
Start-Sleep 60
214-
$statusCode = Invoke-WebRequest https://netsourceindex-staging.azurewebsites.net -UseBasicParsing | select -ExpandProperty StatusCode
215-
if ($statusCode -ne 200) {
216-
Write-Host "##vso[task.logissue type=error;]Deployed website returned undexpected status code $statusCode"
171+
$urls = @(
172+
"https://netsourceindex-staging.azurewebsites.net",
173+
"https://netsourceindex-staging.azurewebsites.net/System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/String.cs.html"
174+
)
175+
foreach ($url in $urls) {
176+
$statusCode = Invoke-WebRequest $url -UseBasicParsing -SkipHttpErrorCheck | select -ExpandProperty StatusCode
177+
if ($statusCode -ne 200) {
178+
Write-Host "##vso[task.logissue type=error;]Deployed website returned undexpected status code $statusCode from url $url"
179+
Write-Host "##vso[task.complete result=Failed;]Deployed website returned undexpected status code $statusCode from url $url"
180+
}
217181
}
218182
displayName: Test Deployed WebApp
219183

build.proj

+9-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
<Target Name="Clean" DependsOnTargets="BuildTasks">
1414
<MSBuild Projects="src/index/index.proj" Targets="Clean" Properties="SourceIndexerTasksAssembly=$(SourceIndexerTasksAssembly)"/>
1515
</Target>
16-
<Target Name="Build" DependsOnTargets="BuildTasks">
17-
<MSBuild Projects="src/index/index.proj" Targets="Build" Properties="SourceIndexerTasksAssembly=$(SourceIndexerTasksAssembly)"/>
18-
</Target>
1916
<Target Name="Clone" DependsOnTargets="BuildTasks">
2017
<MSBuild Projects="src/index/index.proj" Targets="Clone" Properties="SourceIndexerTasksAssembly=$(SourceIndexerTasksAssembly)"/>
2118
</Target>
19+
<Target Name="Prepare" DependsOnTargets="BuildTasks">
20+
<MSBuild Projects="src/index/index.proj" Targets="Prepare" Properties="SourceIndexerTasksAssembly=$(SourceIndexerTasksAssembly)"/>
21+
</Target>
22+
<Target Name="BuildIndex" DependsOnTargets="BuildTasks">
23+
<MSBuild Projects="src/index/index.proj" Targets="BuildIndex" Properties="SourceIndexerTasksAssembly=$(SourceIndexerTasksAssembly)"/>
24+
</Target>
25+
<Target Name="Build" DependsOnTargets="BuildTasks">
26+
<MSBuild Projects="src/index/index.proj" Targets="Build" Properties="SourceIndexerTasksAssembly=$(SourceIndexerTasksAssembly)"/>
27+
</Target>
2228
<Target Name="SelectProjects" DependsOnTargets="BuildTasks">
2329
<MSBuild Projects="src/index/index.proj" Targets="SelectProjects" Properties="SourceIndexerTasksAssembly=$(SourceIndexerTasksAssembly)"/>
2430
</Target>

src/SourceBrowser/src/BinLogParser/BinLogParser.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313

1414
<ItemGroup>
15+
<PackageReference Include="Microsoft.Build" Version="17.2.0" NoWarn="NU1701" />
16+
<PackageReference Include="Microsoft.IO.Redist" Version="6.0.0" NoWarn="NU1701" />
1517
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(NuGetVersionRoslyn)" />
1618
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(NuGetVersionRoslyn)" />
1719
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="$(NuGetVersionRoslyn)" />

src/SourceBrowser/src/BinLogParser/BinLogReader.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public static string TrimCompilerExeFromCommandLine(string commandLine, Compiler
160160

161161
foreach (var trim in stringsToTrim)
162162
{
163-
if (commandLine.StartsWith(trim))
163+
if (commandLine.StartsWith(trim, StringComparison.Ordinal))
164164
{
165165
return commandLine.Substring(trim.Length);
166166
}

src/SourceBrowser/src/BinLogToSln/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void Main(string[] args)
153153
string projectRelativePath;
154154
string outputFile;
155155
string link = null;
156-
if (repoRelativePath.StartsWith("..\\") || repoRelativePath.StartsWith("../") || Path.IsPathRooted(repoRelativePath))
156+
if (repoRelativePath.StartsWith("..\\", StringComparison.Ordinal) || repoRelativePath.StartsWith("../", StringComparison.Ordinal) || Path.IsPathRooted(repoRelativePath))
157157
{
158158
string externalPath = Path.Join("_external", idx++.ToString(), Path.GetFileName(filePath));
159159
// not in the repo dir, treat as external
@@ -163,7 +163,7 @@ static void Main(string[] args)
163163
else
164164
{
165165
projectRelativePath = Path.GetRelativePath(invocation.ProjectDirectory, filePath);
166-
if (projectRelativePath.StartsWith(".."))
166+
if (projectRelativePath.StartsWith("..", StringComparison.Ordinal))
167167
{
168168
link = repoRelativePath;
169169
}

src/SourceBrowser/src/Common/Common.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<DefineConstants>$(DefineConstants);NET472</DefineConstants>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.Build" Version="16.8.0" />
12+
<PackageReference Include="Microsoft.Build" Version="17.2.0" NoWarn="NU1701" />
13+
<PackageReference Include="Microsoft.IO.Redist" Version="6.0.0" NoWarn="NU1701" />
1314
<PackageReference Include="System.Reactive" Version="5.0.0" />
1415
</ItemGroup>
1516
</Project>

src/SourceBrowser/src/HtmlGenerator/HtmlGenerator.csproj

+26-9
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
<DebugType>embedded</DebugType>
1111
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1212
<EmbedUntrackedSources>true</EmbedUntrackedSources>
13+
<NoWarn>$(NoWarn);VSTHRD200</NoWarn>
1314
</PropertyGroup>
1415
<PropertyGroup>
1516
<NuGetPackageId>SourceBrowser</NuGetPackageId>
1617
<NuSpecFile>$(MSBuildProjectDirectory)\$(NuGetPackageId).nuspec</NuSpecFile>
1718
<NuGetVersion>1.0.38</NuGetVersion>
18-
<NuGetVersionRoslyn>4.0.0-1.final</NuGetVersionRoslyn>
19+
<NuGetVersionRoslyn>4.2.0</NuGetVersionRoslyn>
1920
</PropertyGroup>
2021
<ItemGroup>
2122
<NuGetInput Include="$(MSBuildThisFile)" />
@@ -33,15 +34,32 @@
3334
</Content>
3435
</ItemGroup>
3536
<ItemGroup>
36-
<PackageReference Include="ExceptionAnalysis.Diagnostics" Version="1.0.0.39796" />
37-
<PackageReference Include="ManagedEsent" Version="2.0.0" />
38-
<PackageReference Include="Microsoft.Build" Version="16.10.0" ExcludeAssets="runtime" />
39-
<PackageReference Include="Microsoft.Build.Framework" Version="16.10.0" ExcludeAssets="runtime" />
40-
<PackageReference Include="Microsoft.Build.Locator" Version="1.4.1" />
37+
<PackageReference Include="Microsoft.Build.Locator" Version="1.5.3" />
38+
39+
<!-- All Dlls provided in the msbuild install, they need to have ExcludeAssets="runtime" on them -->
40+
<PackageReference Include="Microsoft.Build" Version="17.2.0" ExcludeAssets="runtime" />
41+
<PackageReference Include="Microsoft.Build.Framework" Version="17.2.0" ExcludeAssets="runtime" />
4142
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="16.10.0" ExcludeAssets="runtime" />
4243
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.10.0" ExcludeAssets="runtime" />
44+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" ExcludeAssets="runtime" />
45+
<PackageReference Include="Microsoft.IO.Redist" Version="6.0.0" ExcludeAssets="runtime" />
46+
<PackageReference Include="Microsoft.NET.StringTools" Version="1.0.0" ExcludeAssets="runtime" />
47+
<PackageReference Include="System.Buffers" Version="4.5.1" ExcludeAssets="runtime" />
48+
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" ExcludeAssets="runtime" />
49+
<PackageReference Include="System.Memory" Version="4.5.5" ExcludeAssets="runtime" />
50+
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" ExcludeAssets="runtime" />
51+
<PackageReference Include="System.Reflection.Metadata" Version="6.0.0" ExcludeAssets="runtime" />
52+
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" ExcludeAssets="runtime" />
53+
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" ExcludeAssets="runtime" />
54+
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" ExcludeAssets="runtime" />
55+
<PackageReference Include="System.Text.Json" Version="6.0.5" ExcludeAssets="runtime" />
56+
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="6.0.0" ExcludeAssets="runtime" />
57+
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" ExcludeAssets="runtime" />
58+
<PackageReference Include="System.ValueTuple" Version="4.5.0" ExcludeAssets="runtime" />
59+
60+
<PackageReference Include="ExceptionAnalysis.Diagnostics" Version="1.0.0.39796" />
4361
<PackageReference Include="Microsoft.CodeAnalysis" Version="$(NuGetVersionRoslyn)" />
44-
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2">
62+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
4563
<PrivateAssets>all</PrivateAssets>
4664
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4765
</PackageReference>
@@ -53,11 +71,10 @@
5371
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="$(NuGetVersionRoslyn)" />
5472
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="$(NuGetVersionRoslyn)" />
5573
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="$(NuGetVersionRoslyn)" />
56-
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.507" />
74+
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.669" />
5775
<PackageReference Include="GuiLabs.Language.Xml" Version="1.2.46" />
5876
<PackageReference Include="Microsoft.VisualStudio.Language.Intellisense" Version="16.10.230" />
5977
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
60-
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
6178
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.0-beta-20204-02" PrivateAssets="All" />
6279
</ItemGroup>
6380
<ItemGroup>

src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.HighlightReferences.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Microsoft.SourceBrowser.HtmlGenerator
55
{
66
public partial class DocumentGenerator
77
{
8-
private readonly Dictionary<ISymbol, int> localIds = new Dictionary<ISymbol, int>();
8+
private readonly Dictionary<ISymbol, int> localIds = new Dictionary<ISymbol, int>(SymbolEqualityComparer.Default);
99

1010
private HtmlElementInfo HighlightDefinition(ISymbol declaredSymbol)
1111
{

src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.Links.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private void AddReferencesToImplementedMembers(
358358
{
359359
foreach (var member in implementedInterface.GetMembers())
360360
{
361-
if (declaringType.FindImplementationForInterfaceMember(member) == declaredSymbol)
361+
if (declaredSymbol.Equals(declaringType.FindImplementationForInterfaceMember(member), SymbolEqualityComparer.Default))
362362
{
363363
ProcessReference(
364364
range,

src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.References.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private ReferenceKind DetermineReferenceKind(SyntaxToken token, SyntaxNode node,
255255
SemanticModel.GetDeclaredSymbol(typeDeclaration) is INamedTypeSymbol derivedType &&
256256
referencedSymbol is INamedTypeSymbol baseSymbol)
257257
{
258-
if (baseSymbol.TypeKind == TypeKind.Class && baseSymbol.Equals(derivedType.BaseType))
258+
if (baseSymbol.TypeKind == TypeKind.Class && baseSymbol.Equals(derivedType.BaseType, SymbolEqualityComparer.Default))
259259
{
260260
kind = ReferenceKind.DerivedType;
261261
}
@@ -551,10 +551,10 @@ private string GetAssemblyFromSymbol(ISymbol symbol)
551551
type = (ITypeSymbol)GetTypeFromSymbol(symbol);
552552
string containingAssembly = type.ContainingAssembly.Name;
553553
string typeDocId = (type?.OriginalDefinition ?? type).GetDocumentationCommentId();
554-
var seenAssemblies = new HashSet<string>();
554+
var seenAssemblies = new HashSet<string>();
555555
while (projectGenerator.SolutionGenerator.TypeForwards.TryGetValue((containingAssembly, typeDocId), out var newAssembly))
556556
{
557-
bool loop = !seenAssemblies.Add(newAssembly);
557+
bool loop = !seenAssemblies.Add(newAssembly);
558558
lock (projectGenerator.ForwardedReferenceAssemblies)
559559
{
560560
projectGenerator.ForwardedReferenceAssemblies.Add(
@@ -564,12 +564,12 @@ private string GetAssemblyFromSymbol(ISymbol symbol)
564564
if (loop)
565565
{
566566
break;
567-
}
567+
}
568568

569569
containingAssembly = newAssembly;
570570
}
571571

572-
return containingAssembly;
572+
return containingAssembly;
573573
}
574574

575575
private static ISymbol GetTypeFromSymbol(ISymbol symbol)

src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/DocumentGenerator.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public async Task Generate()
5858
this.getBindableParentDelegate = (Func<SyntaxToken, SyntaxNode>)
5959
Delegate.CreateDelegate(typeof(Func<SyntaxToken, SyntaxNode>), SyntaxFactsService, getBindableParent);
6060

61-
this.DeclaredSymbols = new HashSet<ISymbol>();
61+
this.DeclaredSymbols = new HashSet<ISymbol>(SymbolEqualityComparer.Default);
6262

6363
Interlocked.Increment(ref projectGenerator.DocumentCount);
6464
Interlocked.Add(ref projectGenerator.LinesOfCode, Text.Lines.Count);
@@ -148,7 +148,7 @@ private async Task GenerateHtml(StreamWriter writer)
148148

149149
// pass a value larger than 0 to generate line numbers in JavaScript (to reduce HTML size)
150150
var prefix = Markup.GetDocumentPrefix(title, relativePathToRoot, pregenerateLineNumbers ? 0 : lineCount);
151-
writer.Write(prefix);
151+
await writer.WriteAsync(prefix);
152152
GenerateHeader(writer.WriteLine);
153153

154154
var ranges = (await classifier.Classify(Document, Text))?.ToArray();
@@ -158,11 +158,11 @@ private async Task GenerateHtml(StreamWriter writer)
158158
DocumentUrl,
159159
pregenerateLineNumbers ? lineCount : 0,
160160
GenerateGlyphs(ranges));
161-
writer.WriteLine(table);
161+
await writer.WriteLineAsync(table);
162162

163163
GeneratePre(ranges, writer, lineCount);
164164
var suffix = Markup.GetDocumentSuffix();
165-
writer.WriteLine(suffix);
165+
await writer.WriteLineAsync(suffix);
166166
}
167167

168168
private ISymbol GetSymbolForRange(Classification.Range r)

src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/MetadataAsSource.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static Solution LoadMetadataAsSourceSolution(string assemblyFilePath)
9090
addSourceToAsync = ReflectAddSourceToAsync(metadataAsSourceService);
9191
}
9292

93-
var texts = new Dictionary<INamedTypeSymbol, string>();
93+
var texts = new Dictionary<INamedTypeSymbol, string>(SymbolEqualityComparer.Default);
9494

9595
Parallel.ForEach(
9696
types,
@@ -106,11 +106,14 @@ public static Solution LoadMetadataAsSourceSolution(string assemblyFilePath)
106106

107107
if (Configuration.GenerateMetadataAsSourceBodies)
108108
{
109+
// inside Parallel.ForEach so synchronous block is acceptable
110+
#pragma warning disable VSTHRD002
109111
var document = addSourceToAsync(
110112
tempDocument,
111113
type,
112114
CancellationToken.None).Result;
113115
text = document.GetTextAsync().Result.ToString();
116+
#pragma warning restore VSTHRD002
114117
}
115118

116119
lock (texts)

src/SourceBrowser/src/HtmlGenerator/Pass1-Generation/ProjectGenerator.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public ProjectGenerator(SolutionGenerator solutionGenerator, Project project) :
3535
this.SolutionGenerator = solutionGenerator;
3636
this.Project = project;
3737
this.ProjectFilePath = project.FilePath ?? solutionGenerator.ProjectFilePath;
38-
this.DeclaredSymbols = new Dictionary<ISymbol, string>();
39-
this.BaseMembers = new Dictionary<ISymbol, ISymbol>();
38+
this.DeclaredSymbols = new Dictionary<ISymbol, string>(SymbolEqualityComparer.Default);
39+
this.BaseMembers = new Dictionary<ISymbol, ISymbol>(SymbolEqualityComparer.Default);
4040
this.ImplementedInterfaceMembers = new MultiDictionary<ISymbol, ISymbol>();
4141
this.assemblyAttributesFileName = MetadataAsSource.GeneratedAssemblyAttributesFileName + (project.Language == LanguageNames.CSharp ? ".cs" : ".vb");
4242
PluginSymbolVisitors = SolutionGenerator.PluginAggregator?.ManufactureSymbolVisitors(project).ToArray();
@@ -167,7 +167,7 @@ public async Task Generate()
167167
GenerateIndex();
168168
}
169169

170-
var compilation = Project.GetCompilationAsync().Result;
170+
var compilation = await Project.GetCompilationAsync();
171171
var diagnostics = compilation.GetDiagnostics().Select(d => d.ToString()).ToArray();
172172
if (diagnostics.Length > 0)
173173
{

0 commit comments

Comments
 (0)