Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;

internal sealed class VisualStudioProjectCreationInfo : ProjectSystemProjectCreationInfo
{
public IVsHierarchy? Hierarchy { get; set; }
public Guid ProjectGuid { get; set; }
public IVsHierarchy? Hierarchy { get; init; }
public Guid ProjectGuid { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ public VisualStudioProjectFactory(
});
}

public Task<ProjectSystemProject> CreateAndAddToWorkspaceAsync(string projectSystemName, string language, CancellationToken cancellationToken)
=> CreateAndAddToWorkspaceAsync(projectSystemName, language, new VisualStudioProjectCreationInfo(), cancellationToken);

public async Task<ProjectSystemProject> CreateAndAddToWorkspaceAsync(
string projectSystemName, string language, VisualStudioProjectCreationInfo creationInfo, CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Workspaces.AnalyzerRedirecting
Imports Microsoft.VisualStudio.LanguageServices.Implementation.Diagnostics
Imports Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Framework
Imports Roslyn.Test.Utilities
Expand All @@ -21,7 +22,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function RemoveAndReAddInSameBatchWorksCorrectly() As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesNoFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"Project", LanguageNames.CSharp, CancellationToken.None)
"Project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)
Const analyzerPath = "Z:\TestAnalyzer.dll"

project.AddAnalyzerReference(analyzerPath)
Expand All @@ -43,7 +44,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function LoadDiagnosticsRemovedOnAnalyzerReferenceRemoval(removeInBatch As Boolean) As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesNoFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"Project", LanguageNames.CSharp, CancellationToken.None)
"Project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)
Dim analyzerPath = "Z:\TestAnalyzer" + Guid.NewGuid().ToString() + ".dll"

project.AddAnalyzerReference(analyzerPath)
Expand All @@ -63,7 +64,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function LoadDiagnosticsRemovedOnProjectRemoval(removeInBatch As Boolean) As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesNoFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"Project", LanguageNames.CSharp, CancellationToken.None)
"Project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)
Dim analyzerPath = "Z:\TestAnalyzer" + Guid.NewGuid().ToString() + ".dll"

project.AddAnalyzerReference(analyzerPath)
Expand All @@ -82,7 +83,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function LoadDiagnosticsStayIfRemoveAndAddInBatch() As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesNoFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"Project", LanguageNames.CSharp, CancellationToken.None)
"Project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)
Dim analyzerPath = "Z:\TestAnalyzer" + Guid.NewGuid().ToString() + ".dll"

project.AddAnalyzerReference(analyzerPath)
Expand Down Expand Up @@ -112,7 +113,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
}

Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"Project", LanguageNames.CSharp, CancellationToken.None)
"Project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)

' add Razor source generator and a couple more other analyzer files:
Dim path1 = Path.Combine(TempRoot.Root, "Sdks", "Microsoft.NET.Sdk.Razor", "source-generators", "Microsoft.NET.Sdk.Razor.SourceGenerators.dll")
Expand All @@ -128,7 +129,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function CodeStyleAnalyzers_CSharp_FromSdk_AreIgnored() As Task
Using environment = New TestEnvironment()
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"Project", LanguageNames.CSharp, CancellationToken.None)
"Project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)

' Ensure HasSdkCodeStyleAnalyzers is proper.
Assert.False(project.HasSdkCodeStyleAnalyzers)
Expand Down Expand Up @@ -169,7 +170,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function CodeStyleAnalyzers_VisualBasic_FromSdk_AreIgnored() As Task
Using environment = New TestEnvironment()
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"Project", LanguageNames.VisualBasic, CancellationToken.None)
"Project", LanguageNames.VisualBasic, New VisualStudioProjectCreationInfo(), CancellationToken.None)

' Ensure HasSdkCodeStyleAnalyzers is proper.
Assert.False(project.HasSdkCodeStyleAnalyzers)
Expand Down Expand Up @@ -209,7 +210,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function RedirectedAnalyzers_CSharp() As Task
Using environment = New TestEnvironment(GetType(Redirector))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"Project", LanguageNames.CSharp, CancellationToken.None)
"Project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)

' Add analyzers
project.AddAnalyzerReference(Path.Combine(TempRoot.Root, "Sdks", "Microsoft.NET.Sdk", "analyzers", "Microsoft.CodeAnalysis.NetAnalyzers.dll"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Framework
Imports Roslyn.Test.Utilities

Expand All @@ -16,7 +17,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function AddAndRemoveFileWhenDynamicFileInfoProviderProducesNothing() As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesNoFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"project", LanguageNames.CSharp, CancellationToken.None)
"project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)

Const DynamicFileName As String = "DynamicFile.cshtml"

Expand All @@ -30,7 +31,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function AddAndRemoveFileWhenDynamicFileInfoProviderProducesSomething() As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"project", LanguageNames.CSharp, CancellationToken.None)
"project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)

Const DynamicFileName As String = "DynamicFile.cshtml"

Expand All @@ -52,7 +53,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function DynamicFileNamesAreCaseInsensitive() As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"project", LanguageNames.CSharp, CancellationToken.None)
"project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)

project.AddDynamicSourceFile("DynamicFile.cshtml", ImmutableArray(Of String).Empty)

Expand All @@ -64,7 +65,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function AddAndRemoveFileAndAddAgain() As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"project", LanguageNames.CSharp, CancellationToken.None)
"project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)

Const DynamicFileName As String = "DynamicFile.cshtml"

Expand All @@ -80,7 +81,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
Public Async Function AddAndRemoveExtensionlessFile() As Task
Using environment = New TestEnvironment(GetType(TestDynamicFileInfoProviderThatProducesFiles))
Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"project", LanguageNames.CSharp, CancellationToken.None)
"project", LanguageNames.CSharp, New VisualStudioProjectCreationInfo(), CancellationToken.None)

Const DynamicFileName As String = "DynamicFile"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
<CombinatorialData>
Public Async Function FileChangeAfterRemovalInUncommittedBatchIgnored(withDirectoryWatch As Boolean) As Task
Using environment = New TestEnvironment()
Dim projectInfo = New VisualStudioProjectCreationInfo

' If we have a project directory, then we'll also have a watch for the entire directory;
' test both cases
If withDirectoryWatch Then
projectInfo.FilePath = "Z:\Project.csproj"
End If

Dim projectInfo = New VisualStudioProjectCreationInfo With {
.FilePath = If(withDirectoryWatch, "Z:\Project.csproj", Nothing)
}

Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"project", LanguageNames.CSharp, projectInfo, CancellationToken.None)
Expand All @@ -40,13 +39,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
<CombinatorialData>
Public Async Function FileChangeAfterRemoveOfProjectIgnored(withDirectoryWatch As Boolean) As Task
Using environment = New TestEnvironment()
Dim projectInfo = New VisualStudioProjectCreationInfo

' If we have a project directory, then we'll also have a watch for the entire directory;
' test both cases
If withDirectoryWatch Then
projectInfo.FilePath = "Z:\Project.csproj"
End If
Dim projectInfo = New VisualStudioProjectCreationInfo With {
.FilePath = If(withDirectoryWatch, "Z:\Project.csproj", Nothing)
}

Dim project = Await environment.ProjectFactory.CreateAndAddToWorkspaceAsync(
"project", LanguageNames.CSharp, projectInfo, CancellationToken.None)
Expand Down
Loading
Loading