10 instantiations of ObjectReference
Microsoft.CodeAnalysis.Test.Utilities (3)
ObjectReference.cs (3)
22return new ObjectReference<T>(targetFactory(arg)); 31return new ObjectReference<T>(targetFactory()); 36return new ObjectReference<T>(target);
Microsoft.CodeAnalysis.UnitTests (1)
InternalUtilities\WeakListTests.cs (1)
40return new ObjectReference<C>(new C(value));
Microsoft.CodeAnalysis.Workspaces.UnitTests (6)
SolutionTests\SolutionTests.cs (6)
3534return new ObjectReference<SourceText>(observedText); 3565return new ObjectReference<SourceText>(observedText); 3591return new ObjectReference<SyntaxNode>(observedTree); 3617return new ObjectReference<SyntaxNode>(observedTree); 3732return new ObjectReference<Compilation>(observed); 3757return new ObjectReference<Compilation>(observed);
71 references to ObjectReference
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (1)
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (1)
3867var modelWeakReference = ObjectReference.CreateFromFactory(() => compilation.GetSemanticModel(tree));
Microsoft.CodeAnalysis.Test.Utilities (6)
ObjectReference.cs (6)
19public static ObjectReference<T> CreateFromFactory<T, TArg>(Func<TArg, T> targetFactory, TArg arg) 29public static ObjectReference<T> CreateFromFactory<T>(Func<T> targetFactory) where T : class 34public static ObjectReference<T> Create<T>(T target) where T : class 124throw new InvalidOperationException($"The strong reference being held by the {nameof(ObjectReference<T>)} was retrieved via a call to {nameof(GetReference)}. Since the CLR might have cached a temporary somewhere in your stack, assertions can no longer be made about the correctness of lifetime."); 174public ObjectReference<TResult> GetObjectReference<TResult>(Func<T, TResult> function) where TResult : class 186public ObjectReference<TResult> GetObjectReference<TResult, TArg>(Func<T, TArg, TResult> function, TArg argument) where TResult : class
Microsoft.CodeAnalysis.UnitTests (18)
InternalUtilities\WeakListTests.cs (18)
38private ObjectReference<C> Create(string value) 44private void Add(WeakList<object> list, ObjectReference<C> value) 52var a = Create("a"); 53var b = Create("B"); 54var c = Create("C"); 55var d = Create("D"); 56var e = Create("E"); 108var a = Create("A"); 120var b = Create("B"); 139var a = Create("A"); 140var b = Create("B"); 170var a = Create("A"); 171var b = Create("B"); 210var a = Create("A"); 211var b = Create("B"); 250var a = Create("A"); 251var b = Create("B"); 290var b = Create("B");
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (5)
VisualStudioMSBuildWorkspaceTests.cs (5)
2843var sol = ObjectReference.CreateFromFactory(() => MSBuildWorkspace.Create().OpenSolutionAsync(GetSolutionFileName("TestSolution.sln")).Result); 2844var workspace = sol.GetObjectReference(static s => s.Workspace); 2845var project = sol.GetObjectReference(static s => s.Projects.First()); 2846var document = project.GetObjectReference(static p => p.Documents.First()); 2852var compilation = document.GetObjectReference(static d => d.GetSemanticModelAsync(CancellationToken.None).Result);
Microsoft.CodeAnalysis.Workspaces.UnitTests (19)
SolutionTests\SolutionTests.cs (18)
3303var observedText = GetObservedText(sol, did, text1); 3374var observed = GetObservedText(sol, did, text); 3520var observed = GetObservedText(sol, did, text); 3525private static ObjectReference<SourceText> GetObservedText(Solution solution, DocumentId documentId, string expectedText = null) 3551var observed = GetObservedTextAsync(sol, did, text); 3556private static ObjectReference<SourceText> GetObservedTextAsync(Solution solution, DocumentId documentId, string expectedText = null) 3583var observed = GetObservedSyntaxTreeRoot(sol, did); 3588private static ObjectReference<SyntaxNode> GetObservedSyntaxTreeRoot(Solution solution, DocumentId documentId) 3609var observed = GetObservedSyntaxTreeRootAsync(sol, did); 3614private static ObjectReference<SyntaxNode> GetObservedSyntaxTreeRootAsync(Solution solution, DocumentId documentId) 3678var observed = GetObservedSyntaxTreeRootAsync(sol, did); 3697var observed2 = GetObservedSyntaxTreeRootAsync(doc2.Project.Solution, did); 3724var observed = GetObservedCompilationAsync(sol, pid); 3729private static ObjectReference<Compilation> GetObservedCompilationAsync(Solution solution, ProjectId projectId) 3749var observed = GetObservedCompilation(sol, pid); 3754private static ObjectReference<Compilation> GetObservedCompilation(Solution solution, ProjectId projectId) 5469var sourceTextToRelease = ObjectReference.CreateFromFactory(static () => SourceText.From(Guid.NewGuid().ToString())); 5470var solutionWithSourceTextToRelease = sourceTextToRelease.GetObjectReference(
WorkspaceTests\AdhocWorkspaceTests.cs (1)
584var adhocWorkspaceReference = ObjectReference.CreateFromFactory(
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
ProjectSystemShim\LifetimeTests.cs (1)
23var project = ObjectReference.CreateFromFactory(() => CSharpHelpers.CreateCSharpProject(environment, "Test"));
Roslyn.VisualStudio.Next.UnitTests (21)
Services\SolutionServiceTests.cs (21)
992var objectReference = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1011var objectReference = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1044var objectReference1 = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1045var objectReference2 = ObjectReference.CreateFromFactory(() => document2.GetSemanticModelAsync().GetAwaiter().GetResult()); 1084var objectReference1 = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1085var objectReference2 = ObjectReference.CreateFromFactory(() => document2.GetSemanticModelAsync().GetAwaiter().GetResult()); 1086var objectReference3 = ObjectReference.CreateFromFactory(() => document3.GetSemanticModelAsync().GetAwaiter().GetResult()); 1107var objectReference1 = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1116var objectReference2 = ObjectReference.CreateFromFactory(() => syncedSolution.GetRequiredDocument(document1.Id).GetSemanticModelAsync().GetAwaiter().GetResult()); 1134var objectReference1 = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1145var objectReference2 = ObjectReference.CreateFromFactory(() => syncedSolution.GetRequiredDocument(document1.Id).GetSemanticModelAsync().GetAwaiter().GetResult()); 1163var objectReference1 = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1179var objectReference2 = ObjectReference.CreateFromFactory(() => syncedSolution.GetRequiredDocument(document1.Id).GetSemanticModelAsync().GetAwaiter().GetResult()); 1216var objectReference1_step1 = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1217var objectReference2_step1 = ObjectReference.CreateFromFactory(() => document2.GetSemanticModelAsync().GetAwaiter().GetResult()); 1233var oopDocumentReference1_step1 = ObjectReference.CreateFromFactory(() => syncedSolution.GetRequiredDocument(document1.Id).GetSemanticModelAsync().GetAwaiter().GetResult()); 1234var oopDocumentReference2_step1 = ObjectReference.CreateFromFactory(() => syncedSolution.GetRequiredDocument(document2.Id).GetSemanticModelAsync().GetAwaiter().GetResult()); 1242var objectReference1_step2 = ObjectReference.CreateFromFactory(() => document1.GetSemanticModelAsync().GetAwaiter().GetResult()); 1243var objectReference2_step2 = ObjectReference.CreateFromFactory(() => document2.GetSemanticModelAsync().GetAwaiter().GetResult()); 1252var oopDocumentReference1_step2 = ObjectReference.CreateFromFactory(() => syncedSolution.GetRequiredDocument(document1.Id).GetSemanticModelAsync().GetAwaiter().GetResult()); 1253var oopDocumentReference2_step2 = ObjectReference.CreateFromFactory(() => syncedSolution.GetRequiredDocument(document2.Id).GetSemanticModelAsync().GetAwaiter().GetResult());