Skip to content

Commit

Permalink
Add multiple target frameworks to SubSolution.Builders.Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ReMinoer committed Oct 18, 2021
1 parent e0083ab commit 1af1560
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Sources/SubSolution.Builders/SolutionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private async Task FilterProjectsAsync(ProjectsBase projects, Dictionary<string,
{
Log("Filter projects: " + filter.TextFormat);

IEnumerable<string> 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);
}
Expand Down Expand Up @@ -751,7 +751,7 @@ static private void RemoveEmptySubFolders(Solution.Folder folder)
foreach (Solution.Folder subFolder in folder.SubFolders.Values)
RemoveEmptySubFolders(subFolder);

IEnumerable<string> 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);
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/SubSolution/Raw/RawSolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -95,7 +95,7 @@ static public async Task<RawSolution> 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);
Expand Down
24 changes: 12 additions & 12 deletions Tests/SubSolution.Builders.Tests/SolutionBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ private async Task<SolutionBuilderContext> 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);
checkSolution = await solutionConverter.ConvertAsync(rawSolution, context.SolutionDirectoryPath);
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);
Expand All @@ -207,7 +207,7 @@ private async Task<SolutionBuilderContext> 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);
Expand All @@ -219,7 +219,7 @@ private async Task<SolutionBuilderContext> 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);
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFrameworks>net5.0;netcoreapp3.1;net461</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down

0 comments on commit 1af1560

Please sign in to comment.