Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Jul 14, 2024
1 parent e93916b commit abeb8af
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<DebugType>embedded</DebugType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!--<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>-->
</PropertyGroup>

<PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion source/Nuke.Common/Nuke.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<MSBuildWarningsAsErrors>$(MSBuildWarningsAsErrors);CS8785</MSBuildWarningsAsErrors>
<NoWarn>$(NoWarn);SYSLIB0050;SYSLIB0051</NoWarn>
<!--<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>-->
</PropertyGroup>

</Project>
13 changes: 7 additions & 6 deletions source/Nuke.Tooling/SettingsEntity.NewInstance.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Maintainers of NUKE.
// Copyright 2024 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

Expand All @@ -7,6 +7,7 @@
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using JetBrains.Annotations;

#pragma warning disable SYSLIB0011

namespace Nuke.Common.Tooling;
Expand All @@ -17,20 +18,20 @@ public static partial class SettingsEntityExtensions
public static T NewInstance<T>(this T settingsEntity)
where T : ISettingsEntity
{
AppContext.SetSwitch("System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization", true);
AppContext.SetSwitch("System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization", isEnabled: true);

var binaryFormatter = new BinaryFormatter();

using var memoryStream = new MemoryStream();
binaryFormatter.Serialize(memoryStream, settingsEntity);
memoryStream.Seek(offset: 0, loc: SeekOrigin.Begin);

var newInstance = (T) binaryFormatter.Deserialize(memoryStream);
var newInstance = (T)binaryFormatter.Deserialize(memoryStream);
if (newInstance is ToolSettings toolSettings)
{
toolSettings.ProcessArgumentConfigurator = ((ToolSettings) (object) settingsEntity).ProcessArgumentConfigurator;
toolSettings.ProcessLogger = ((ToolSettings) (object) settingsEntity).ProcessLogger;
toolSettings.ProcessExitHandler = ((ToolSettings) (object) settingsEntity).ProcessExitHandler;
toolSettings.ProcessArgumentConfigurator = ((ToolSettings)(object)settingsEntity).ProcessArgumentConfigurator;
toolSettings.ProcessLogger = ((ToolSettings)(object)settingsEntity).ProcessLogger;
toolSettings.ProcessExitHandler = ((ToolSettings)(object)settingsEntity).ProcessExitHandler;
}

return newInstance;
Expand Down

0 comments on commit abeb8af

Please sign in to comment.