-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency on deprecated ref package #74814
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Basic.Reference.Assemblies; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.FindSymbols; | ||
using Microsoft.CodeAnalysis.Test.Utilities; | ||
|
@@ -23,6 +24,22 @@ public class FindReferencesTests : TestBase | |
private static Workspace CreateWorkspace(Type[] additionalParts = null) | ||
=> new AdhocWorkspace(FeaturesTestCompositions.Features.AddParts(additionalParts).GetHostServices()); | ||
|
||
private static Solution AddProjectWithMetadataReferences(Solution solution, string projectName, string languageName, string code, IEnumerable<MetadataReference> metadataReference, params ProjectId[] projectReferences) | ||
{ | ||
var suffix = languageName == LanguageNames.CSharp ? "cs" : "vb"; | ||
var pid = ProjectId.CreateNewId(); | ||
var did = DocumentId.CreateNewId(pid); | ||
var pi = ProjectInfo.Create( | ||
pid, | ||
VersionStamp.Default, | ||
projectName, | ||
projectName, | ||
languageName, | ||
metadataReferences: metadataReference, | ||
projectReferences: projectReferences.Select(p => new ProjectReference(p))); | ||
return solution.AddProject(pi).AddDocument(did, $"{projectName}.{suffix}", SourceText.From(code)); | ||
} | ||
|
||
private static Solution AddProjectWithMetadataReferences(Solution solution, string projectName, string languageName, string code, MetadataReference metadataReference, params ProjectId[] projectReferences) | ||
{ | ||
var suffix = languageName == LanguageNames.CSharp ? "cs" : "vb"; | ||
|
@@ -352,9 +369,9 @@ public interface I | |
{ | ||
System.Uri Get(); | ||
} | ||
}", NetStandard20Ref); | ||
}", NetStandard20.References.All); | ||
|
||
solution = AddProjectWithMetadataReferences(solution, "DesktopProject", LanguageNames.CSharp, @" | ||
solution = AddProjectWithMetadataReferences(solution, "NetCoreProject", LanguageNames.CSharp, @" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the test here from being a Waiting for @sharwell, @jasonmalinowski or @CyrusNajmabadi to sign off on this or let me know if I missed a subtle issue about this test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably went with testing netstandard and .NET Framework since they'd be most "different" in terms of types being in different assemblies. Is there a reason we can't keep this a .NET Framework ref? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It's difficult to keep the
I assure you they are quite different in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
OK that would worry me less here; as long as we have some test that is asserting that we can handle the cases where System.Object comes from different assemblies, we're probably good. |
||
using N; | ||
|
||
namespace N2 | ||
|
@@ -366,12 +383,9 @@ public System.Uri Get() | |
return null; | ||
} | ||
} | ||
}", SystemRef_v46, solution.Projects.Single(pid => pid.Name == "NetStandardProject").Id); | ||
|
||
var desktopProject = solution.Projects.First(p => p.Name == "DesktopProject"); | ||
solution = solution.AddMetadataReferences(desktopProject.Id, [MscorlibRef_v46, Net46StandardFacade]); | ||
}", NetCoreApp.References, solution.Projects.Single(pid => pid.Name == "NetStandardProject").Id); | ||
|
||
desktopProject = solution.GetProject(desktopProject.Id); | ||
var netCoreProject = solution.Projects.First(p => p.Name == "NetCoreProject"); | ||
var netStandardProject = solution.Projects.First(p => p.Name == "NetStandardProject"); | ||
|
||
var interfaceMethod = (IMethodSymbol)(await netStandardProject.GetCompilationAsync()).GetTypeByMetadataName("N.I").GetMembers("Get").First(); | ||
|
@@ -383,7 +397,7 @@ public System.Uri Get() | |
foreach (var r in references) | ||
projectIds.Add(solution.GetOriginatingProjectId(r.Definition)); | ||
|
||
Assert.True(projectIds.Contains(desktopProject.Id)); | ||
Assert.True(projectIds.Contains(netCoreProject.Id)); | ||
} | ||
|
||
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35786")] | ||
|
@@ -416,7 +430,7 @@ interface ITestBase | |
|
||
using var workspace = CreateWorkspace(); | ||
var solution = GetMultipleDocumentSolution(workspace, [implText, interface1Text, interface2Text]); | ||
solution = solution.AddMetadataReferences(solution.ProjectIds.Single(), [MscorlibRef_v46, Net46StandardFacade, SystemRef_v46, NetStandard20Ref]); | ||
solution = solution.AddMetadataReferences(solution.ProjectIds.Single(), NetFramework.References); | ||
|
||
var project = solution.Projects.Single(); | ||
var compilation = await project.GetCompilationAsync(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The grim reaper advances another door.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only three doors left.