Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
global-json-file: global.json
Copy link
Member

Choose a reason for hiding this comment

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

❤️

- name: Restore source-indexer.sln
run: dotnet restore src/source-indexer.sln
- name: Build source-indexer.sln
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.404",
"version": "9.0.203",
"rollForward": "major"
}
}
2 changes: 1 addition & 1 deletion src/SourceBrowser.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2b57a3d551d02c05b90d006f48cfa07c0a7e5cd2
bf64cd8ac09f60e605e1a86784da47cc2c034a89
3 changes: 3 additions & 0 deletions src/SourceBrowser/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ bld/
# Visual Studo 2015 cache/options directory
.vs/

# Rider
.idea/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
Expand Down
16 changes: 15 additions & 1 deletion src/SourceBrowser/TestCode/Project2/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,18 @@ static TargetedTypeNewTest Create()
{
return new(new());
}
}
}

class TypeWithPrimaryConstructor(A a, B b)
{
public A A => a;
public B[] ArrayOfB => [b];
}

class EmptyType;

class TypeWithAllowsRefStruct<T>
where T : allows ref struct
{
public static T Return(T value) => value;
}
2 changes: 1 addition & 1 deletion src/SourceBrowser/src/BinLogParser/BinLogParser.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net9.0</TargetFrameworks>
<AssemblyName>BinLogParser</AssemblyName>
<RootNamespace>Microsoft.SourceBrowser.BinLogParser</RootNamespace>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/SourceBrowser/src/BinLogToSln/BinLogToSln.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<PackAsTool>true</PackAsTool>
<RollForward>Major</RollForward>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
2 changes: 1 addition & 1 deletion src/SourceBrowser/src/Common/Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Microsoft.SourceBrowser.Common</AssemblyName>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net9.0</TargetFrameworks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
Expand Down
8 changes: 7 additions & 1 deletion src/SourceBrowser/src/Common/PriorityQueue.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using System.Collections.Generic;
using System.Diagnostics;

// WARNING: this class has a bug!
// See here for an explanation:
// https://github.com/dotnet/wpf/blob/bcd972664606974adc09f7f1b8c7a9a14c33c899/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/LegacyPriorityQueue.cs#L21
// I don't care enough to switch to the new implementation, but it's important to leave this notice here.
// We copied the old code before the fix was made in the WPF sources.

namespace Microsoft.SourceBrowser.Common
{
/// <summary>
Expand Down Expand Up @@ -207,4 +213,4 @@ public void PushRange(IEnumerable<T> list)
}
}
}
}
}
48 changes: 24 additions & 24 deletions src/SourceBrowser/src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@

<ItemGroup>
<!-- msbuild-->
<PackageVersion Include="Microsoft.Build.Framework" Version="17.5.0" />
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="17.5.0" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.5.0" />
<PackageVersion Include="Microsoft.Build" Version="17.5.0" />
<PackageVersion Include="Microsoft.Build.Framework" Version="17.12.6" />
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="17.12.6" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.12.6" />
<PackageVersion Include="Microsoft.Build" Version="17.12.6" />

<!-- component governance -->
<PackageVersion Include="Microsoft.IO.Redist" Version="6.0.1" />

<!-- roslyn -->
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.2.0" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Features" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Features" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.Workspaces" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.12.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.12.0" />

<!-- roslyn analyzer -->
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
Expand All @@ -40,30 +40,30 @@
<PackageVersion Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageVersion Include="xunit" Version="2.4.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Shouldly" Version="4.0.3" />

<!-- other dependencies -->
<PackageVersion Include="LibGit2Sharp" Version="0.29.0" />
<PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.169" />
<PackageVersion Include="ManagedEsent" Version="1.9.4" />
<PackageVersion Include="System.Reactive" Version="5.0.0" />
<PackageVersion Include="System.Composition" Version="6.0.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="System.Composition" Version="8.0.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />

<PackageVersion Include="System.Buffers" Version="4.5.1" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageVersion Include="System.Buffers" Version="4.6.0" />
<PackageVersion Include="System.Memory" Version="4.6.0" />
<PackageVersion Include="System.Numerics.Vectors" Version="4.6.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />

<PackageVersion Include="Microsoft.Build.Locator" Version="1.5.3" />
<PackageVersion Include="Microsoft.NET.StringTools" Version="17.5.0" />
<PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
<PackageVersion Include="Microsoft.NET.StringTools" Version="17.12.6" />
<PackageVersion Include="Microsoft.VisualStudio.Language.Intellisense" Version="16.10.230" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.0-beta-20204-02" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />

<PackageVersion Include="ExceptionAnalysis.Diagnostics" Version="1.0.0.39796" />
<PackageVersion Include="GuiLabs.Language.Xml" Version="1.2.46" />
<PackageVersion Include="GuiLabs.Language.Xml" Version="1.2.88" />

<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.1" />
Expand Down
15 changes: 13 additions & 2 deletions src/SourceBrowser/src/HtmlGenerator/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public CommandLineOptions(
IReadOnlyList<string> pluginBlacklist,
bool loadPlugins,
bool excludeTests,
string rootPath)
string rootPath,
bool includeSourceGeneratedDocuments)
{
SolutionDestinationFolder = solutionDestinationFolder;
Projects = projects;
Expand All @@ -38,13 +39,15 @@ public CommandLineOptions(
LoadPlugins = loadPlugins;
ExcludeTests = excludeTests;
RootPath = rootPath;
IncludeSourceGeneratedDocuments = includeSourceGeneratedDocuments;
}

public string SolutionDestinationFolder { get; }
public IReadOnlyList<string> Projects { get; }
public IReadOnlyDictionary<string, string> Properties { get; }
public bool EmitAssemblyList { get; }
public bool DoNotIncludeReferencedProjects { get; }
public bool IncludeSourceGeneratedDocuments { get; }
public bool Force { get; }
public bool NoBuiltInFederations { get; }
public IReadOnlyDictionary<string, string> OfflineFederations { get; }
Expand All @@ -70,6 +73,7 @@ public static CommandLineOptions Parse(params string[] args)
var pluginBlacklist = new List<string>();
var loadPlugins = false;
var excludeTests = false;
var includeSourceGeneratedDocuments = true;
var rootPath = (string)null;

foreach (var arg in args)
Expand Down Expand Up @@ -216,6 +220,12 @@ public static CommandLineOptions Parse(params string[] args)
continue;
}

if (arg == "/excludeSourceGeneratedDocuments")
{
includeSourceGeneratedDocuments = false;
continue;
}

if (arg.StartsWith("/root:", StringComparison.Ordinal))
{
rootPath = Path.GetFullPath(arg.Substring("/root:".Length).StripQuotes());
Expand Down Expand Up @@ -259,7 +269,8 @@ public static CommandLineOptions Parse(params string[] args)
pluginBlacklist,
loadPlugins,
excludeTests,
rootPath);
rootPath,
includeSourceGeneratedDocuments);
}

private static void AddProject(List<string> projects, string path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.SourceBrowser.HtmlGenerator
{
public partial class Classification
{
public async Task<IEnumerable<Range>> Classify(Document document, SourceText text)
public async Task<IEnumerable<Range>> ClassifyAsync(Document document, SourceText text)
{
var span = TextSpan.FromBounds(0, text.Length);

Expand Down Expand Up @@ -181,6 +181,7 @@ private Range CreateRange(SourceText text, TextSpan span, string classification)
["delegate name"] = Constants.ClassificationTypeName,
["record name"] = Constants.ClassificationTypeName,
["record class name"] = Constants.ClassificationTypeName,
["record struct name"] = Constants.ClassificationTypeName,
["module name"] = Constants.ClassificationTypeName,
["type parameter name"] = Constants.ClassificationTypeName,
["preprocessor keyword"] = Constants.ClassificationPreprocessKeyword,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,12 @@ private void AddReferencesToImplementedMembers(
{
var declaringType = declaredSymbol.ContainingType;
var interfaces = declaringType.AllInterfaces;
var comparer = SymbolEqualityComparer.Default;
foreach (var implementedInterface in interfaces)
{
foreach (var member in implementedInterface.GetMembers())
{
if (declaredSymbol.Equals(declaringType.FindImplementationForInterfaceMember(member), SymbolEqualityComparer.Default))
if (comparer.Equals(declaredSymbol, declaringType.FindImplementationForInterfaceMember(member)))
{
ProcessReference(
range,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public DocumentGenerator(
this.Document = document;
}

public async Task Generate()
public async Task GenerateAsync()
{
if (Configuration.CalculateRoslynSemantics)
{
Expand Down Expand Up @@ -113,15 +113,15 @@ public async Task Generate()
append: false,
encoding: Encoding.UTF8))
{
await GenerateHtml(streamWriter);
await GenerateHtmlAsync(streamWriter);
}
}
else
{
using (var memoryStream = new MemoryStream())
using (var streamWriter = new StreamWriter(memoryStream))
{
await GeneratePre(streamWriter);
await GeneratePreAsync(streamWriter);
}
}
}
Expand All @@ -137,7 +137,7 @@ private void CalculateRelativePathToRoot()
this.relativePathToRoot = Paths.CalculateRelativePathToRoot(documentDestinationFilePath, SolutionDestinationFolder);
}

private async Task GenerateHtml(StreamWriter writer)
private async Task GenerateHtmlAsync(StreamWriter writer)
{
var title = Document.Name;
var lineCount = Text.Lines.Count;
Expand All @@ -151,7 +151,7 @@ private async Task GenerateHtml(StreamWriter writer)
await writer.WriteAsync(prefix);
GenerateHeader(writer.WriteLine);

var ranges = (await classifier.Classify(Document, Text))?.ToArray();
var ranges = (await classifier.ClassifyAsync(Document, Text))?.ToArray();

// pass a value larger than 0 to generate line numbers statically at HTML generation time
var table = Markup.GetTablePrefix(
Expand Down Expand Up @@ -285,9 +285,9 @@ private void GenerateHeader(Action<string> writeLine)
projectLink: (Display: projectGenerator.ProjectSourcePath, Url: "/#" + Document.Project.AssemblyName, projectGenerator.AssemblyName));
}

private async Task GeneratePre(StreamWriter writer, int lineCount = 0)
private async Task GeneratePreAsync(StreamWriter writer, int lineCount = 0)
{
var ranges = await classifier.Classify(Document, Text);
var ranges = await classifier.ClassifyAsync(Document, Text);
GeneratePre(ranges, writer, lineCount);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class MetadataAsSource
{
private static Func<Document, ISymbol, CancellationToken, Task<Document>> addSourceToAsync = null;

private static Func<Document, ISymbol, CancellationToken, Task<Document>> ReflectAddSourceToAsync(object service)
private static Func<Document, ISymbol, CancellationToken, Task<Document>> ReflectAddSourceTo(object service)
{
var assembly = Assembly.Load("Microsoft.CodeAnalysis.Features");
var type = assembly.GetType("Microsoft.CodeAnalysis.MetadataAsSource.IMetadataAsSourceService");
Expand Down Expand Up @@ -87,7 +87,7 @@ public static Solution LoadMetadataAsSourceSolution(string assemblyFilePath)
var metadataAsSourceService = WorkspaceHacks.GetMetadataAsSourceService(tempDocument);
if (addSourceToAsync == null)
{
addSourceToAsync = ReflectAddSourceToAsync(metadataAsSourceService);
addSourceToAsync = ReflectAddSourceTo(metadataAsSourceService);
}

var texts = new Dictionary<INamedTypeSymbol, string>(SymbolEqualityComparer.Default);
Expand Down
Loading