forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to ensure that a CompletionService can be acquired
Issue dotnet#11841 found that, due to a MEF bug, the Features assemblies could not properly be included in a MEF composition. This was worked around by combining [ExtensionOrder] attributes where multiple attributes had been specified. This change adds a tests for C# and VB to ensure that a CompletionService can be acquired from an AdhocWorkspace that is created with MefHostServices that include the Features assemblies. I verified that these tests fail without the workaound described above, and pass with the workaround in place.
- Loading branch information
1 parent
76aef21
commit 649f22c
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/EditorFeatures/CSharpTest/Completion/CompletionServiceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Linq; | ||
using Microsoft.CodeAnalysis.Completion; | ||
using Microsoft.CodeAnalysis.CSharp.Completion; | ||
using Microsoft.CodeAnalysis.Host.Mef; | ||
using Roslyn.Test.Utilities; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion | ||
{ | ||
public class CompletionServiceTests | ||
{ | ||
[Fact, Trait(Traits.Feature, Traits.Features.Completion)] | ||
public void AcquireCompletionService() | ||
{ | ||
var hostServices = MefHostServices.Create( | ||
MefHostServices.DefaultAssemblies.Concat( | ||
new[] | ||
{ | ||
typeof(CompletionService).Assembly, | ||
typeof(CSharpCompletionService).Assembly | ||
})); | ||
|
||
var workspace = new AdhocWorkspace(hostServices); | ||
|
||
var document = workspace | ||
.AddProject("TestProject", LanguageNames.CSharp) | ||
.AddDocument("TestDocument.cs", ""); | ||
|
||
var service = CompletionService.GetService(document); | ||
Assert.NotNull(service); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/EditorFeatures/VisualBasicTest/Completion/CompletionServiceTests.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
Imports Microsoft.CodeAnalysis.Completion | ||
Imports Microsoft.CodeAnalysis.Host.Mef | ||
Imports Microsoft.CodeAnalysis.VisualBasic.Completion | ||
|
||
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Completion | ||
Public Class CompletionServiceTests | ||
<Fact, Trait(Traits.Feature, Traits.Features.Completion)> | ||
Public Sub AcquireCompletionService() | ||
Dim hostServices = MefHostServices.Create( | ||
MefHostServices.DefaultAssemblies.Concat({ | ||
GetType(CompletionService).Assembly, | ||
GetType(VisualBasicCompletionService).Assembly})) | ||
|
||
Dim workspace = New AdhocWorkspace(hostServices) | ||
|
||
Dim document = workspace _ | ||
.AddProject("TestProject", LanguageNames.VisualBasic) _ | ||
.AddDocument("TestDocument.vb", String.Empty) | ||
|
||
Dim service = CompletionService.GetService(document) | ||
Assert.NotNull(service) | ||
End Sub | ||
End Class | ||
End Namespace |