diff --git a/Sources/SubSolution.Builders/SolutionBuilder.cs b/Sources/SubSolution.Builders/SolutionBuilder.cs index 7f01561..5674874 100644 --- a/Sources/SubSolution.Builders/SolutionBuilder.cs +++ b/Sources/SubSolution.Builders/SolutionBuilder.cs @@ -469,7 +469,7 @@ private async Task FilterProjectsAsync(ProjectsBase projects, Dictionary ignoredProjectPaths = matchingProjectByPath.Where(x => !filter.Match((x.Key, x.Value))).Select(x => x.Key); + string[] ignoredProjectPaths = matchingProjectByPath.Where(x => !filter.Match((x.Key, x.Value))).Select(x => x.Key).ToArray(); foreach (string ignoredProjectPath in ignoredProjectPaths) matchingProjectByPath.Remove(ignoredProjectPath); } @@ -751,7 +751,7 @@ static private void RemoveEmptySubFolders(Solution.Folder folder) foreach (Solution.Folder subFolder in folder.SubFolders.Values) RemoveEmptySubFolders(subFolder); - IEnumerable emptySubFolderNames = folder.SubFolders.Where(x => x.Value.IsEmpty).Select(x => x.Key); + string[] emptySubFolderNames = folder.SubFolders.Where(x => x.Value.IsEmpty).Select(x => x.Key).ToArray(); foreach (string emptySubFolderName in emptySubFolderNames) folder.RemoveSubFolder(emptySubFolderName); } diff --git a/Sources/SubSolution/Raw/RawSolution.cs b/Sources/SubSolution/Raw/RawSolution.cs index 30020d2..dd48c8c 100644 --- a/Sources/SubSolution/Raw/RawSolution.cs +++ b/Sources/SubSolution/Raw/RawSolution.cs @@ -44,7 +44,7 @@ public RawSolution() public async Task WriteAsync(Stream stream) { - await using IAsyncDisposable _ = new StreamWriter(stream, new UTF8Encoding(true), -1, leaveOpen: true) + await using IAsyncDisposable _ = new StreamWriter(stream, new UTF8Encoding(true), 1024, leaveOpen: true) .AsAsyncDisposable(out StreamWriter writer); await writer.WriteLineAsync(); @@ -95,7 +95,7 @@ static public async Task ReadAsync(Stream stream) { RawSolution solution = new RawSolution(); - using StreamReader reader = new StreamReader(stream, new UTF8Encoding(true), true, -1, leaveOpen: true); + using StreamReader reader = new StreamReader(stream, new UTF8Encoding(true), true, 1024, leaveOpen: true); solution.SlnFormatVersion = await ReadNextLineVersionAsync(reader, SlnFormatVersionHeaderPrefix); solution.MajorVisualStudioVersion = await ReadNextLineIntegerAsync(reader, MajorVisualStudioVersionHeaderPrefix); diff --git a/Tests/SubSolution.Builders.Tests/SolutionBuilderTests.cs b/Tests/SubSolution.Builders.Tests/SolutionBuilderTests.cs index 9e5e7ca..e3868c6 100644 --- a/Tests/SubSolution.Builders.Tests/SolutionBuilderTests.cs +++ b/Tests/SubSolution.Builders.Tests/SolutionBuilderTests.cs @@ -184,7 +184,7 @@ private async Task PrepareContextAsync(SubSolutionConfig RawSolution rawSolution; rawSolution = rawSolutionConverter.Convert(checkSolution); - await using var firstPassStream = new MemoryStream(); + using var firstPassStream = new MemoryStream(); await rawSolution.WriteAsync(firstPassStream); firstPassStream.Position = 0; rawSolution = await RawSolution.ReadAsync(firstPassStream); @@ -192,7 +192,7 @@ private async Task PrepareContextAsync(SubSolutionConfig solutionConverter.Issues.Should().BeEmpty(); rawSolution = rawSolutionConverter.Convert(checkSolution); - await using var secondPassStream = new MemoryStream(); + using var secondPassStream = new MemoryStream(); await rawSolution.WriteAsync(secondPassStream); secondPassStream.Position = 0; rawSolution = await RawSolution.ReadAsync(secondPassStream); @@ -207,7 +207,7 @@ private async Task PrepareContextAsync(SubSolutionConfig rawSolutionConverter.Update(referenceRawSolution, checkSolution); CheckRawSolutionAreEqual(rawSolution, referenceRawSolution); - await using var thirdPassStream = new MemoryStream(); + using var thirdPassStream = new MemoryStream(); await referenceRawSolution.WriteAsync(thirdPassStream); thirdPassStream.Position = 0; referenceRawSolution = await RawSolution.ReadAsync(thirdPassStream); @@ -219,7 +219,7 @@ private async Task PrepareContextAsync(SubSolutionConfig rawSolutionConverter.Update(referenceRawSolution, checkSolution); CheckRawSolutionAreEqual(rawSolution, referenceRawSolution); - await using var forthPassStream = new MemoryStream(); + using var forthPassStream = new MemoryStream(); await referenceRawSolution.WriteAsync(forthPassStream); forthPassStream.Position = 0; await RawSolution.ReadAsync(forthPassStream); @@ -281,7 +281,7 @@ private async Task ConfigureMockFileSystemAsync(MockGlobPatternFileSystem mockFi relativeFilePath.Add(@"external\MyFramework\external\MySubModule\MySubModule.sln"); relativeFilePath.Add(@"external\MyFramework\external\MySubModule\MySubModule.subsln"); - await AddConfigurationToFileSystemAsync(mySubModuleConfigurationPath + ".subsln", MySubModuleConfiguration); + AddConfigurationToFileSystem(mySubModuleConfigurationPath + ".subsln", MySubModuleConfiguration); await AddSolutionToFileSystemAsync(mySubModuleConfigurationPath + ".sln", MySubModuleConfiguration); mockFileSystem.AddRoot(RootName, relativeFilePath.Select(x => WorkspaceDirectoryRelativePath + x)); @@ -290,7 +290,7 @@ private async Task ConfigureMockFileSystemAsync(MockGlobPatternFileSystem mockFi relativeFilePath.Add(@"external\MyFramework\MyFramework.sln"); relativeFilePath.Add(@"external\MyFramework\MyFramework.subsln"); - await AddConfigurationToFileSystemAsync(myFrameworkConfigurationPath + ".subsln", MyFrameworkConfiguration); + AddConfigurationToFileSystem(myFrameworkConfigurationPath + ".subsln", MyFrameworkConfiguration); await AddSolutionToFileSystemAsync(myFrameworkConfigurationPath + ".sln", MyFrameworkConfiguration); mockFileSystem.AddRoot(RootName, relativeFilePath.Select(x => WorkspaceDirectoryRelativePath + x)); @@ -299,7 +299,7 @@ private async Task ConfigureMockFileSystemAsync(MockGlobPatternFileSystem mockFi relativeFilePath.Add("MyApplication.sln"); relativeFilePath.Add("MyApplication.subsln"); - await AddConfigurationToFileSystemAsync(@"C:\Directory\SubDirectory\MyWorkspace\MyApplication.subsln", configurationContent); + AddConfigurationToFileSystem(@"C:\Directory\SubDirectory\MyWorkspace\MyApplication.subsln", configurationContent); await AddSolutionToFileSystemAsync(@"C:\Directory\SubDirectory\MyWorkspace\MyApplication.sln", configurationContent); mockFileSystem.AddRoot(RootName, relativeFilePath.Select(x => WorkspaceDirectoryRelativePath + x)); @@ -314,16 +314,16 @@ private async Task ConfigureMockFileSystemAsync(MockGlobPatternFileSystem mockFi relativeFilePath.Add(@"Directory\ExternalSolution.sln"); relativeFilePath.Add(@"Directory\ExternalSolution.subsln"); - await AddConfigurationToFileSystemAsync(externalSolutionConfigurationPath + ".subsln", ExternalSolutionConfiguration); + AddConfigurationToFileSystem(externalSolutionConfigurationPath + ".subsln", ExternalSolutionConfiguration); await AddSolutionToFileSystemAsync(externalSolutionConfigurationPath + ".sln", ExternalSolutionConfiguration); mockFileSystem.AddRoot(AlternativeRootName, relativeFilePath); - async Task AddConfigurationToFileSystemAsync(string filePath, SubSolutionConfiguration configuration) + void AddConfigurationToFileSystem(string filePath, SubSolutionConfiguration configuration) { - await using var memoryStream = new MemoryStream(); + using var memoryStream = new MemoryStream(); - await using (TextWriter configurationWriter = new StreamWriter(memoryStream)) + using (TextWriter configurationWriter = new StreamWriter(memoryStream)) configuration.Save(configurationWriter); byte[] content = memoryStream.ToArray(); @@ -341,7 +341,7 @@ async Task AddSolutionToFileSystemAsync(string filePath, SubSolutionConfiguratio var rawSolutionConverter = new SolutionConverter(mockFileSystem); RawSolution rawSolution = rawSolutionConverter.Convert(solution); - await using var memoryStream = new MemoryStream(); + using var memoryStream = new MemoryStream(); await rawSolution.WriteAsync(memoryStream); byte[] content = memoryStream.ToArray(); diff --git a/Tests/SubSolution.Builders.Tests/SubSolution.Builders.Tests.csproj b/Tests/SubSolution.Builders.Tests/SubSolution.Builders.Tests.csproj index 622515b..c5e1c38 100644 --- a/Tests/SubSolution.Builders.Tests/SubSolution.Builders.Tests.csproj +++ b/Tests/SubSolution.Builders.Tests/SubSolution.Builders.Tests.csproj @@ -1,7 +1,8 @@ - net5.0 + net5.0;netcoreapp3.1;net461 + 8.0 enable false