From 048cfc2c96df03e9c26f1968f34571a8fd0a1c26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Mon, 13 Jan 2025 10:43:30 -0800
Subject: [PATCH 1/7] Add Microsoft.CodeAnalysis.Workspaces.Common package
dependency.
---
Directory.Packages.props | 1 +
eng/Version.Details.xml | 4 ++++
eng/Versions.props | 1 +
3 files changed, 6 insertions(+)
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 37f12c935a34..cde36c909357 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -28,6 +28,7 @@
+
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 567f4cf9b42b..4a72e20104cf 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -131,6 +131,10 @@
https://github.com/dotnet/roslyn
911cf5f462960bdd01df1ea3c0d0c217b3c3838b
+
+ https://github.com/dotnet/roslyn
+ 911cf5f462960bdd01df1ea3c0d0c217b3c3838b
+
https://github.com/dotnet/roslyn
911cf5f462960bdd01df1ea3c0d0c217b3c3838b
diff --git a/eng/Versions.props b/eng/Versions.props
index 568ef68bf68c..902e8722dfa0 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -215,6 +215,7 @@
4.13.0-3.25057.3
4.13.0-3.25057.3
4.13.0-3.25057.3
+ 4.13.0-3.25057.3
4.13.0-3.25057.3
4.13.0-3.25057.3
From edf940b834fd38efa47fc37e1bd51ab423a85cce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Mon, 13 Jan 2025 10:44:59 -0800
Subject: [PATCH 2/7] Minor fixes.
---
.../GenAPI/Microsoft.DotNet.GenAPI/IAssemblySymbolWriter.cs | 4 ++--
.../Microsoft.DotNet.GenAPI/INamedTypeSymbolExtensions.cs | 4 ++--
.../Microsoft.DotNet.GenAPI/SyntaxGeneratorExtensions.cs | 1 -
.../Filtering/ImplicitSymbolFilter.cs | 2 --
.../NugetPackageDownloadHelpers.cs | 5 ++---
5 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/IAssemblySymbolWriter.cs b/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/IAssemblySymbolWriter.cs
index a739ca961575..e093037b8a78 100644
--- a/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/IAssemblySymbolWriter.cs
+++ b/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/IAssemblySymbolWriter.cs
@@ -11,9 +11,9 @@ namespace Microsoft.DotNet.GenAPI
public interface IAssemblySymbolWriter
{
///
- /// Process a given assembly symbol.
+ /// Write a given assembly symbol to the instance's desired output.
///
- /// representing the loaded assembly.
+ /// An assembly symbol representing the loaded assembly.
void WriteAssembly(IAssemblySymbol assemblySymbol);
}
}
diff --git a/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/INamedTypeSymbolExtensions.cs b/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/INamedTypeSymbolExtensions.cs
index 6d5d6ec8e054..4ef1ecedcf6d 100644
--- a/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/INamedTypeSymbolExtensions.cs
+++ b/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/INamedTypeSymbolExtensions.cs
@@ -69,14 +69,14 @@ private static SyntaxList FromAttributeData(IEnumerable attrs, bool isReadonly)
+ private static SyntaxNode CreateDummyField(string type, string fieldName, SyntaxList attrs, bool isReadonly)
{
List modifiers = new() { SyntaxFactory.Token(SyntaxKind.PrivateKeyword) };
if (isReadonly)
modifiers.Add(SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword));
SyntaxNode declaration = SyntaxFactory.FieldDeclaration(
SyntaxFactory.VariableDeclaration(
- SyntaxFactory.ParseTypeName(typ))
+ SyntaxFactory.ParseTypeName(type))
.WithVariables(
SyntaxFactory.SingletonSeparatedList(
SyntaxFactory.VariableDeclarator(
diff --git a/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/SyntaxGeneratorExtensions.cs b/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/SyntaxGeneratorExtensions.cs
index 6618d47a20b1..3af277f65c4a 100644
--- a/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/SyntaxGeneratorExtensions.cs
+++ b/src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI/SyntaxGeneratorExtensions.cs
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System.Transactions;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/Filtering/ImplicitSymbolFilter.cs b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/Filtering/ImplicitSymbolFilter.cs
index 1fe0da2e0450..a86ee9cff67a 100644
--- a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/Filtering/ImplicitSymbolFilter.cs
+++ b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/Filtering/ImplicitSymbolFilter.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.CodeAnalysis;
-using Microsoft.DotNet.ApiSymbolExtensions;
-using Microsoft.DotNet.ApiSymbolExtensions.Filtering;
namespace Microsoft.DotNet.ApiSymbolExtensions.Filtering
{
diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs b/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
index 5bd803d3fabc..0131e3aa180b 100644
--- a/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
+++ b/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
@@ -81,7 +81,7 @@ public static ImmutableArray DownloadPackages()
}
bool found = false;
- ILogger logger = NullLogger.Instance;
+ ILogger log = NullLogger.Instance;
CancellationToken cancellationToken = CancellationToken.None;
SourceCacheContext cache = new SourceCacheContext();
using (var packageFile = File.Create(packagePath))
@@ -96,7 +96,7 @@ public static ImmutableArray DownloadPackages()
packageVersion,
packageFile,
cache,
- logger,
+ log,
cancellationToken);
if (found)
@@ -112,4 +112,3 @@ public static ImmutableArray DownloadPackages()
return packagePath;
}
}
-
From 7514742c924121a09fe2ece014e050b73bbb7be2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Mon, 13 Jan 2025 10:45:37 -0800
Subject: [PATCH 3/7] Add IAssemblySymbol.LoadAssembliesAsDictionary.
---
.../AssemblySymbolLoader.cs | 23 +++++++++++++++++++
.../IAssemblySymbolLoader.cs | 7 ++++++
2 files changed, 30 insertions(+)
diff --git a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
index 1d6921dd1f92..bc588dea2c5a 100644
--- a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
+++ b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
@@ -100,6 +100,29 @@ public void AddReferenceSearchPaths(params string[] paths)
return assemblySymbols;
}
+ ///
+ public IDictionary LoadAssembliesAsDictionary(params string[] paths)
+ {
+ // First resolve all assemblies that are passed in and create metadata references out of them.
+ // Reference assemblies of the passed in assemblies that themselves are passed in, will be skipped to be resolved,
+ // as they are resolved as part of the loop below.
+ ImmutableHashSet fileNames = paths.Select(path => Path.GetFileName(path)).ToImmutableHashSet();
+ List assembliesToReturn = LoadFromPaths(paths, fileNames);
+
+ // Create IAssemblySymbols out of the MetadataReferences.
+ // Doing this after resolving references to make sure that references are available.
+ Dictionary assemblySymbols = [];
+ foreach (MetadataReference metadataReference in assembliesToReturn)
+ {
+ if(_cSharpCompilation.GetAssemblyOrModuleSymbol(metadataReference) is IAssemblySymbol assemblySymbol)
+ {
+ assemblySymbols.Add(assemblySymbol.Name, assemblySymbol);
+ }
+ }
+
+ return assemblySymbols;
+ }
+
///
public IReadOnlyList LoadAssembliesFromArchive(string archivePath, IReadOnlyList relativePaths)
{
diff --git a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/IAssemblySymbolLoader.cs b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/IAssemblySymbolLoader.cs
index 161ead0aea87..e0696e3317e8 100644
--- a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/IAssemblySymbolLoader.cs
+++ b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/IAssemblySymbolLoader.cs
@@ -25,6 +25,13 @@ public interface IAssemblySymbolLoader
/// The list of resolved .
IReadOnlyList LoadAssemblies(params string[] paths);
+ ///
+ /// Loads a set of assemblies from the filesystem and gets their corresponding instances as a dictionary.
+ ///
+ /// List of paths to load binaries from. Can be full paths to binaries or directories.
+ /// The dictionary of resolved instances,excluding those which resolved as .
+ IDictionary LoadAssembliesAsDictionary(params string[] paths);
+
///
/// Loads assemblies from an archive based on the given relative paths.
///
From f039de9e55730c39621ab12494b75b0a6fe88098 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Tue, 14 Jan 2025 15:46:07 -0800
Subject: [PATCH 4/7] revert change to unrelated file
---
.../NugetPackageDownloadHelpers.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs b/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
index 0131e3aa180b..2dd942fc213a 100644
--- a/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
+++ b/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
@@ -81,7 +81,7 @@ public static ImmutableArray DownloadPackages()
}
bool found = false;
- ILogger log = NullLogger.Instance;
+ ILogger logger = NullLogger.Instance;
CancellationToken cancellationToken = CancellationToken.None;
SourceCacheContext cache = new SourceCacheContext();
using (var packageFile = File.Create(packagePath))
@@ -96,7 +96,7 @@ public static ImmutableArray DownloadPackages()
packageVersion,
packageFile,
cache,
- log,
+ logger,
cancellationToken);
if (found)
@@ -111,4 +111,4 @@ public static ImmutableArray DownloadPackages()
}
return packagePath;
}
-}
+}
\ No newline at end of file
From b726cdd68e418df3b9bc79887a90a00156f49031 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Tue, 14 Jan 2025 15:50:40 -0800
Subject: [PATCH 5/7] Add AssemblySymbolLoader factory method that consumes
LoadAssembliesAsDictionary.
---
.../AssemblySymbolLoader.cs | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
index bc588dea2c5a..7bc838c5e0e5 100644
--- a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
+++ b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
@@ -35,6 +35,32 @@ public class AssemblySymbolLoader : IAssemblySymbolLoader
///
public const string AssemblyReferenceNotFoundErrorCode = "CP1002";
+ ///
+ /// Creates an assembly symbol loader and its corresponding assembly symbols from the given DLL files in the filesystem.
+ ///
+ /// The logger instance to use for message logging.
+ /// A collection of paths where the assembly DLLs should be searched.
+ /// An optional collection of paths where the assembly references should be searched.
+ /// Whether to include internal symbols or not.
+ /// A tuple containing an assembly symbol loader and its corresponding dictionary of assembly symbols.
+ public static (AssemblySymbolLoader, Dictionary) CreateFromFiles(ILog logger, string[] assembliesPaths, string[]? assemblyReferencesPaths, bool respectInternals = false)
+ {
+ if (assembliesPaths.Length == 0)
+ {
+ return (new AssemblySymbolLoader(logger, resolveAssemblyReferences: true, includeInternalSymbols: respectInternals), new Dictionary());
+ }
+
+ bool atLeastOneReferencePath = assemblyReferencesPaths?.Count() > 0;
+ AssemblySymbolLoader loader = new(logger, resolveAssemblyReferences: atLeastOneReferencePath, respectInternals);
+ if (atLeastOneReferencePath)
+ {
+ loader.AddReferenceSearchPaths(assemblyReferencesPaths!);
+ }
+ Dictionary dictionary = new(loader.LoadAssembliesAsDictionary(assembliesPaths));
+
+ return (loader, dictionary);
+ }
+
///
/// Creates a new instance of the class.
///
From 000fb7d3969fd73f45d5c2b42ae76143a3adcd00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Tue, 14 Jan 2025 16:02:56 -0800
Subject: [PATCH 6/7] Make LoadAssembliesAsDictionary
---
.../AssemblySymbolLoader.cs | 46 +++++++++----------
.../IAssemblySymbolLoader.cs | 7 ---
2 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
index 7bc838c5e0e5..5fda5bdaac45 100644
--- a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
+++ b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/AssemblySymbolLoader.cs
@@ -126,29 +126,6 @@ public void AddReferenceSearchPaths(params string[] paths)
return assemblySymbols;
}
- ///
- public IDictionary LoadAssembliesAsDictionary(params string[] paths)
- {
- // First resolve all assemblies that are passed in and create metadata references out of them.
- // Reference assemblies of the passed in assemblies that themselves are passed in, will be skipped to be resolved,
- // as they are resolved as part of the loop below.
- ImmutableHashSet fileNames = paths.Select(path => Path.GetFileName(path)).ToImmutableHashSet();
- List assembliesToReturn = LoadFromPaths(paths, fileNames);
-
- // Create IAssemblySymbols out of the MetadataReferences.
- // Doing this after resolving references to make sure that references are available.
- Dictionary assemblySymbols = [];
- foreach (MetadataReference metadataReference in assembliesToReturn)
- {
- if(_cSharpCompilation.GetAssemblyOrModuleSymbol(metadataReference) is IAssemblySymbol assemblySymbol)
- {
- assemblySymbols.Add(assemblySymbol.Name, assemblySymbol);
- }
- }
-
- return assemblySymbols;
- }
-
///
public IReadOnlyList LoadAssembliesFromArchive(string archivePath, IReadOnlyList relativePaths)
{
@@ -344,6 +321,29 @@ private List LoadFromPaths(IEnumerable paths, Immutab
return result;
}
+ // Loads a set of assemblies from the filesystem and gets their corresponding instances as a dictionary.
+ private IDictionary LoadAssembliesAsDictionary(params string[] paths)
+ {
+ // First resolve all assemblies that are passed in and create metadata references out of them.
+ // Reference assemblies of the passed in assemblies that themselves are passed in, will be skipped to be resolved,
+ // as they are resolved as part of the loop below.
+ ImmutableHashSet fileNames = paths.Select(path => Path.GetFileName(path)).ToImmutableHashSet();
+ List assembliesToReturn = LoadFromPaths(paths, fileNames);
+
+ // Create IAssemblySymbols out of the MetadataReferences.
+ // Doing this after resolving references to make sure that references are available.
+ Dictionary assemblySymbols = [];
+ foreach (MetadataReference metadataReference in assembliesToReturn)
+ {
+ if (_cSharpCompilation.GetAssemblyOrModuleSymbol(metadataReference) is IAssemblySymbol assemblySymbol)
+ {
+ assemblySymbols.Add(assemblySymbol.Name, assemblySymbol);
+ }
+ }
+
+ return assemblySymbols;
+ }
+
private MetadataReference CreateOrGetMetadataReferenceFromPath(string path, ImmutableHashSet? referenceAssemblyNamesToIgnore = null)
{
// Roslyn doesn't support having two assemblies as references with the same identity and then getting the symbol for it.
diff --git a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/IAssemblySymbolLoader.cs b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/IAssemblySymbolLoader.cs
index e0696e3317e8..161ead0aea87 100644
--- a/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/IAssemblySymbolLoader.cs
+++ b/src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/IAssemblySymbolLoader.cs
@@ -25,13 +25,6 @@ public interface IAssemblySymbolLoader
/// The list of resolved .
IReadOnlyList LoadAssemblies(params string[] paths);
- ///
- /// Loads a set of assemblies from the filesystem and gets their corresponding instances as a dictionary.
- ///
- /// List of paths to load binaries from. Can be full paths to binaries or directories.
- /// The dictionary of resolved instances,excluding those which resolved as .
- IDictionary LoadAssembliesAsDictionary(params string[] paths);
-
///
/// Loads assemblies from an archive based on the given relative paths.
///
From 7e755063b20eacc9b8a80be203d108a851eb5a08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20S=C3=A1nchez=20L=C3=B3pez?=
<1175054+carlossanlop@users.noreply.github.com>
Date: Tue, 14 Jan 2025 16:10:21 -0800
Subject: [PATCH 7/7] Revert changes to unrelated file (for real now)
---
.../NugetPackageDownloadHelpers.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs b/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
index 2dd942fc213a..5bd803d3fabc 100644
--- a/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
+++ b/src/SourceBuild/content/test/Microsoft.DotNet.UnifiedBuild.Tests/NugetPackageDownloadHelpers.cs
@@ -111,4 +111,5 @@ public static ImmutableArray DownloadPackages()
}
return packagePath;
}
-}
\ No newline at end of file
+}
+