Skip to content

Commit

Permalink
Merge branch 'issue-remove-mono-cecil' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
peters committed Sep 3, 2024
2 parents cfa9124 + a7bb1e5 commit 6cd7f6b
Show file tree
Hide file tree
Showing 24 changed files with 105 additions and 566 deletions.
18 changes: 9 additions & 9 deletions src/Snap.Installer.Tests/ProgramTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ public async Task TestInstall_Offline_Using_Local_PackageSource()
using var genesisPackageContext = await _baseFixturePackaging.BuildPackageAsync(genesisSnapReleaseBuilder, cts.Token);

var releasesFilename = _snapFilesystem.PathCombine(snapInstallerIoEnvironment.ThisExeWorkingDirectory, genesisPackageContext.FullPackageSnapApp.BuildNugetReleasesFilename());
var snapAppDllFilename = _snapFilesystem.PathCombine(snapInstallerIoEnvironment.ThisExeWorkingDirectory, SnapConstants.SnapAppDllFilename);
var snapAppDllFilename = _snapFilesystem.PathCombine(snapInstallerIoEnvironment.ThisExeWorkingDirectory, SnapConstants.SnapAppYamlFilename);
var setupNupkgFilename = _snapFilesystem.PathCombine(snapInstallerIoEnvironment.ThisExeWorkingDirectory, SnapConstants.SetupNupkgFilename);

await using var releasePackageMemoryStream = _snapPack.BuildReleasesPackage(genesisSnapApp, snapAppsReleases);

await _snapFilesystem.FileWriteAsync(genesisPackageContext.FullPackageMemoryStream, setupNupkgFilename, cts.Token);
await _snapFilesystem.FileWriteAsync(releasePackageMemoryStream, releasesFilename, cts.Token);

using var snapAppDllAssemblyDefinition = _snapAppWriter.BuildSnapAppAssembly(genesisSnapApp);
snapAppDllAssemblyDefinition.Write(snapAppDllFilename);
using var snapAppYamlStream = _snapAppWriter.BuildSnapApp(genesisSnapApp);
await _snapFilesystem.FileWriteAsync(snapAppYamlStream, snapAppDllFilename, default);

var (exitCode, installerType) = await Program.MainImplAsync(["--headless"], LogLevel.Info, cts, _snapOsMock.Object, x =>
{
Expand All @@ -142,7 +142,7 @@ public async Task TestInstall_Offline_Using_Local_PackageSource()
{
throw new PlatformNotSupportedException();
}
Assert.EndsWith(SnapConstants.SnapAppDllFilename, files[1]);
Assert.EndsWith(SnapConstants.SnapAppYamlFilename, files[1]);
Assert.EndsWith(SnapConstants.SnapDllFilename, files[2]);
}

Expand Down Expand Up @@ -202,12 +202,12 @@ public async Task TestInstall_Web_Using_Local_PackageSource()
using var update1PackageContext = await _baseFixturePackaging.BuildPackageAsync(update1SnapReleaseBuilder, cts.Token);
using var update2PackageContext = await _baseFixturePackaging.BuildPackageAsync(update2SnapReleaseBuilder, cts.Token);

var snapAppDllFilename = _snapFilesystem.PathCombine(snapInstallerIoEnvironment.ThisExeWorkingDirectory, SnapConstants.SnapAppDllFilename);
var snapAppDllFilename = _snapFilesystem.PathCombine(snapInstallerIoEnvironment.ThisExeWorkingDirectory, SnapConstants.SnapAppYamlFilename);

await using var releasePackageMemoryStream = _snapPack.BuildReleasesPackage(genesisSnapApp, snapAppsReleases);

using var snapAppDllAssemblyDefinition = _snapAppWriter.BuildSnapAppAssembly(genesisSnapApp);
snapAppDllAssemblyDefinition.Write(snapAppDllFilename);
using var snapAppYamlStream = _snapAppWriter.BuildSnapApp(genesisSnapApp);
await _snapFilesystem.FileWriteAsync(snapAppYamlStream, snapAppDllFilename, cts.Token);

await genesisPackageContext.WriteToAsync(packagesDirectory, _snapFilesystem, cts.Token, writeDeltaNupkg: false);
await update1PackageContext.WriteToAsync(packagesDirectory, _snapFilesystem, cts.Token, writeFullNupkg: false);
Expand Down Expand Up @@ -243,7 +243,7 @@ public async Task TestInstall_Web_Using_Local_PackageSource()
throw new PlatformNotSupportedException();
}
Assert.EndsWith(mainExecutable.BuildRuntimeConfigFilename(_snapFilesystem), files[1]);
Assert.EndsWith(SnapConstants.SnapAppDllFilename, files[2]);
Assert.EndsWith(SnapConstants.SnapAppYamlFilename, files[2]);
Assert.EndsWith(SnapConstants.SnapDllFilename, files[3]);
Assert.EndsWith("test1.dll", files[4]);
Assert.EndsWith("test2.dll", files[5]);
Expand All @@ -258,4 +258,4 @@ void SetupSnapOsMock([NotNull] ISnapOsSpecialFolders specialFolders)
_snapOsMock.Setup(x => x.SpecialFolders).Returns(specialFolders);
_snapOsMock.Setup(x => x.ProcessManager).Returns(_snapOsProcessManager);
}
}
}
4 changes: 2 additions & 2 deletions src/Snap.Installer/Program.Install.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async Task InstallInBackgroundAsync(IMainWindowViewModel mainWindowViewModel)
diskLogger.Debug($"{nameof(environment.Io.WorkingDirectory)}: {environment.Io.WorkingDirectory}");
diskLogger.Debug($"{nameof(environment.Io.ThisExeWorkingDirectory)}: {environment.Io.ThisExeWorkingDirectory}");

var snapAppDllAbsolutePath = snapFilesystem.PathCombine(environment.Io.ThisExeWorkingDirectory, SnapConstants.SnapAppDllFilename);
var snapAppDllAbsolutePath = snapFilesystem.PathCombine(environment.Io.ThisExeWorkingDirectory, SnapConstants.SnapAppYamlFilename);
diskLogger.Debug($"{nameof(snapAppDllAbsolutePath)}: {snapAppDllAbsolutePath}.");

if (!snapFilesystem.FileExists(snapAppDllAbsolutePath))
Expand All @@ -110,7 +110,7 @@ async Task InstallInBackgroundAsync(IMainWindowViewModel mainWindowViewModel)
}
catch (Exception ex)
{
mainWindowLogger.ErrorException($"Error reading {SnapConstants.SnapAppDllFilename}", ex);
mainWindowLogger.ErrorException($"Error reading {SnapConstants.SnapAppYamlFilename}", ex);
goto done;
}

Expand Down
1 change: 1 addition & 0 deletions src/Snap.Shared.Tests/Snap.Shared.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="Moq" />
<PackageReference Include="XunitXml.TestLogger" />
<PackageReference Include="Mono.Cecil" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions src/Snap.Tests/Core/Extensions/SnapExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,9 @@ public async Task TestGetSnapAppFromDirectory()
var snapApp = _baseFixture.BuildSnapApp();

await using var tmpDir = _baseFixture.WithDisposableTempDirectory(_fileSystem);
using var assemblyDefinition = _appWriter.BuildSnapAppAssembly(snapApp);
var snapAppDllAbsolutePath = _fileSystem.PathCombine(tmpDir.WorkingDirectory, assemblyDefinition.BuildRelativeFilename());
assemblyDefinition.Write(snapAppDllAbsolutePath);
using var snapAppYamlStream = _appWriter.BuildSnapApp(snapApp);
var snapAppDllAbsolutePath = _fileSystem.PathCombine(tmpDir.WorkingDirectory, SnapConstants.SnapAppYamlFilename);
_fileSystem.FileWrite(snapAppYamlStream, snapAppDllAbsolutePath);

var appSpecAfter = tmpDir.WorkingDirectory.GetSnapAppFromDirectory(_fileSystem, _appReader);
Assert.NotNull(appSpecAfter);
Expand All @@ -622,9 +622,9 @@ public async Task TestGetSnapAppFromDirectory_Supports_Yaml_Member_Aliases()
snapApp.InstallDirectoryName = "mydirectory";

await using var tmpDir = _baseFixture.WithDisposableTempDirectory(_fileSystem);
using var assemblyDefinition = _appWriter.BuildSnapAppAssembly(snapApp);
var snapAppDllAbsolutePath = _fileSystem.PathCombine(tmpDir.WorkingDirectory, assemblyDefinition.BuildRelativeFilename());
assemblyDefinition.Write(snapAppDllAbsolutePath);
using var snapAppYamlStream = _appWriter.BuildSnapApp(snapApp);
var snapAppDllAbsolutePath = _fileSystem.PathCombine(tmpDir.WorkingDirectory, SnapConstants.SnapAppYamlFilename);
_fileSystem.FileWrite(snapAppYamlStream, snapAppDllAbsolutePath);

var appSpecAfter = tmpDir.WorkingDirectory.GetSnapAppFromDirectory(_fileSystem, _appReader);
Assert.NotNull(appSpecAfter);
Expand Down Expand Up @@ -1035,4 +1035,4 @@ static Dictionary<string, string> BuildExpansionProperties(string value)
return properties;
}

}
}
28 changes: 14 additions & 14 deletions src/Snap.Tests/Core/SnapAppWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void TestBuildSnapAppAssembly_Throws_If_Channel_UpdateFeed_Source_Is_Null
snapAppBefore.Channels.ForEach(x => { x.UpdateFeed.Source = null; });
Assert.True(snapAppBefore.Channels.Count > 0);

var ex = Assert.Throws<Exception>(() => _snapAppWriter.BuildSnapAppAssembly(snapAppBefore));
var ex = Assert.Throws<Exception>(() => _snapAppWriter.BuildSnapApp(snapAppBefore));
Assert.StartsWith("Update feed Source cannot be null", ex.Message);
}

Expand All @@ -49,8 +49,8 @@ public void TestBuildSnapAppAssembly()
{
var snapAppBefore = _baseFixture.BuildSnapApp();

using var assembly = _snapAppWriter.BuildSnapAppAssembly(snapAppBefore);
var snapAppAfter = assembly.GetSnapApp(_snapAppReader);
using var snapAppYamlStream = _snapAppWriter.BuildSnapApp(snapAppBefore);
var snapAppAfter = _snapAppReader.BuildSnapAppFromStream(snapAppYamlStream);
Assert.NotNull(snapAppAfter);
}

Expand All @@ -75,8 +75,8 @@ public void TestBuildSnapAppAssembly_Prunes_PushFeed_Credentials()
}
});

using var assembly = _snapAppWriter.BuildSnapAppAssembly(snapAppBefore);
var snapAppAfter = assembly.GetSnapApp(_snapAppReader);
using var snapAppYamlStream = _snapAppWriter.BuildSnapApp(snapAppBefore);
var snapAppAfter = _snapAppReader.BuildSnapAppFromStream(snapAppYamlStream);
Assert.NotNull(snapAppAfter);

var snapAppAfterChannel = snapAppAfter.GetDefaultChannelOrThrow();
Expand Down Expand Up @@ -112,8 +112,8 @@ public void TestBuildSnapAppAssembly_Prunes_UpdateFeed_Credentials_If_Nuget_Org_
},
});

using var assembly = _snapAppWriter.BuildSnapAppAssembly(snapAppBefore);
var snapAppAfter = assembly.GetSnapApp(_snapAppReader);
using var snapAppYamlStream = _snapAppWriter.BuildSnapApp(snapAppBefore);
var snapAppAfter = _snapAppReader.BuildSnapAppFromStream(snapAppYamlStream);
Assert.NotNull(snapAppAfter);

var snapAppAfterChannel = snapAppAfter.GetDefaultChannelOrThrow();
Expand Down Expand Up @@ -163,8 +163,8 @@ public void TestBuildSnapAppAssembly_Prunes_UpdateFeed_ApiKey_But_Allows_Usernam
UpdateFeed = updateFeed
});

using var assembly = _snapAppWriter.BuildSnapAppAssembly(snapAppBefore);
var snapAppAfter = assembly.GetSnapApp(_snapAppReader);
using var snapAppYamlStream = _snapAppWriter.BuildSnapApp(snapAppBefore);
var snapAppAfter = _snapAppReader.BuildSnapAppFromStream(snapAppYamlStream);
Assert.NotNull(snapAppAfter);

var snapAppAfterChannel = snapAppAfter.GetDefaultChannelOrThrow();
Expand Down Expand Up @@ -201,8 +201,8 @@ public void TestBuildSnapAppAssembly_Include_Persistent_Assets()
"somefile.json"
];

using var assembly = _snapAppWriter.BuildSnapAppAssembly(snapAppBefore);
var snapAppAfter = assembly.GetSnapApp(_snapAppReader);
using var snapAppYamlStream = _snapAppWriter.BuildSnapApp(snapAppBefore);
var snapAppAfter = _snapAppReader.BuildSnapAppFromStream(snapAppYamlStream);
Assert.NotNull(snapAppAfter);

Assert.Equal(snapAppBefore.Target.PersistentAssets, snapAppAfter.Target.PersistentAssets);
Expand All @@ -219,10 +219,10 @@ public void TestBuildSnapAppAssembly_Include_Shortcuts()
SnapShortcutLocation.StartMenu
];

using var assembly = _snapAppWriter.BuildSnapAppAssembly(snapAppBefore);
var snapAppAfter = assembly.GetSnapApp(_snapAppReader);
using var snapAppYamlStream = _snapAppWriter.BuildSnapApp(snapAppBefore);
var snapAppAfter = _snapAppReader.BuildSnapAppFromStream(snapAppYamlStream);
Assert.NotNull(snapAppAfter);

Assert.Equal(snapAppBefore.Target.PersistentAssets, snapAppAfter.Target.PersistentAssets);
}
}
}
Loading

0 comments on commit 6cd7f6b

Please sign in to comment.