Skip to content

Commit

Permalink
Merge pull request #9126 from JanKrivanek/proto/remove-binfmt-enablement
Browse files Browse the repository at this point in the history
Removing dead code unit tests and BinFmt enablement
  • Loading branch information
JanKrivanek authored Aug 21, 2023
2 parents 0125fc9 + c87e893 commit 9ae833e
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 296 deletions.
8 changes: 0 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@
<PropertyGroup>
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>

<!--
Serialization/Deserialization of BinaryFormatter throws out System.NotSupportedException with latest .NET.
To work around temporarily add this property. The issues below are tracking this problem.
https://github.com/dotnet/msbuild/issues/9051
https://github.com/dotnet/msbuild/issues/8823
-->
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>

<!--
NU1507: ManagePackageVersionsCentrally implies source mapping, which we should consider turning on but it's nontrivial
NU1603: Microsoft.xunit.netcore.extensions package has dependencies to versions which aren't published, so ignore those warnings
Expand Down
2 changes: 1 addition & 1 deletion src/Build.UnitTests/BackEnd/BuildManager_Logging_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public BuildManager_Logging_Tests(ITestOutputHelper output)

[DotNetOnlyTheory]
[InlineData("1", true)]
[InlineData("0", false)]
// [InlineData("0", true)] <-- explicitly opting out on core will lead to node crash (as documented)
[InlineData(null, true)]
public void Build_WithCustomBuildArgs_NetCore(string envVariableValue, bool isWarningExpected)
=> TestCustomEventWarning<BuildErrorEventArgs>(envVariableValue, isWarningExpected);
Expand Down
15 changes: 13 additions & 2 deletions src/Build.UnitTests/BackEnd/TaskHostFactory_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,21 @@ public void TaskNodesDieAfterBuild()
}
}

[Theory]
[DotNetOnlyTheory]
[InlineData(false)]
// [InlineData(true)] <-- explicitly opting out on core will lead to node crash
public void VariousParameterTypesCanBeTransmittedToAndReceivedFromTaskHost_NetCore(
bool testLegacyImplementation)
=> VariousParameterTypesCanBeTransmittedToAndReceivedFromTaskHost(testLegacyImplementation);

[WindowsFullFrameworkOnlyTheory]
[InlineData(false)]
[InlineData(true)]
public void VariousParameterTypesCanBeTransmittedToAndReceivedFromTaskHost(bool testLegacyImplementation)
public void VariousParameterTypesCanBeTransmittedToAndReceivedFromTaskHost_Framework(
bool testLegacyImplementation)
=> VariousParameterTypesCanBeTransmittedToAndReceivedFromTaskHost(testLegacyImplementation);

private void VariousParameterTypesCanBeTransmittedToAndReceivedFromTaskHost(bool testLegacyImplementation)
{
using TestEnvironment env = TestEnvironment.Create(_output);

Expand Down
36 changes: 0 additions & 36 deletions src/Build.UnitTests/InvalidProjectFileException_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,6 @@ public InvalidProjectFileExceptionTests(ITestOutputHelper output)
_testOutput = output;
}

/// <summary>
/// Verify I implemented ISerializable correctly
/// </summary>
[Fact]
public void SerializeDeserialize()
{
InvalidProjectFileException e = new InvalidProjectFileException(
"projectFile",
1, 2, 3, 4,
"message",
"errorSubcategory",
"errorCode",
"helpKeyword");

using (MemoryStream memstr = new MemoryStream())
{
BinaryFormatter frm = new BinaryFormatter();

frm.Serialize(memstr, e);
memstr.Position = 0;

InvalidProjectFileException e2 = (InvalidProjectFileException)frm.Deserialize(memstr);

Assert.Equal(e.ColumnNumber, e2.ColumnNumber);
Assert.Equal(e.EndColumnNumber, e2.EndColumnNumber);
Assert.Equal(e.EndLineNumber, e2.EndLineNumber);
Assert.Equal(e.ErrorCode, e2.ErrorCode);
Assert.Equal(e.ErrorSubcategory, e2.ErrorSubcategory);
Assert.Equal(e.HasBeenLogged, e2.HasBeenLogged);
Assert.Equal(e.HelpKeyword, e2.HelpKeyword);
Assert.Equal(e.LineNumber, e2.LineNumber);
Assert.Equal(e.Message, e2.Message);
Assert.Equal(e.ProjectFile, e2.ProjectFile);
}
}

/// <summary>
/// Verify that nesting an IPFE copies the error code
/// </summary>
Expand Down
49 changes: 0 additions & 49 deletions src/Build.UnitTests/LoggerException_Tests.cs

This file was deleted.

21 changes: 0 additions & 21 deletions src/Framework.UnitTests/EventArgs_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,6 @@ public void EventArgsCtors()
}
#endregion

/// <summary>
/// Verify a whidbey project started event can be deserialized, the whidbey event is stored in a serialized base64 string.
/// </summary>
[Fact]
public void TestDeserialization()
{
string base64OldProjectStarted = "AAEAAAD/////AQAAAAAAAAAMAgAAAFxNaWNyb3NvZnQuQnVpbGQuRnJhbWV3b3JrLCBWZXJzaW9uPTIuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49YjAzZjVmN2YxMWQ1MGEzYQUBAAAAMU1pY3Jvc29mdC5CdWlsZC5GcmFtZXdvcmsuUHJvamVjdFN0YXJ0ZWRFdmVudEFyZ3MHAAAAC3Byb2plY3RGaWxlC3RhcmdldE5hbWVzFkJ1aWxkRXZlbnRBcmdzK21lc3NhZ2UaQnVpbGRFdmVudEFyZ3MraGVscEtleXdvcmQZQnVpbGRFdmVudEFyZ3Mrc2VuZGVyTmFtZRhCdWlsZEV2ZW50QXJncyt0aW1lc3RhbXAXQnVpbGRFdmVudEFyZ3MrdGhyZWFkSWQBAQEBAQAADQgCAAAABgMAAAALcHJvamVjdEZpbGUGBAAAAAt0YXJnZXROYW1lcwYFAAAAB21lc3NhZ2UGBgAAAAtoZWxwS2V5d29yZAYHAAAAB01TQnVpbGQBl5vjTYvIiAsAAAAL";
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
byte[] binaryObject = Convert.FromBase64String(base64OldProjectStarted);
ms.Write(binaryObject, 0, binaryObject.Length);
ms.Position = 0;
ProjectStartedEventArgs pse = (ProjectStartedEventArgs)bf.Deserialize(ms);
pse.Message.ShouldBe("message", StringCompareShould.IgnoreCase);
pse.ProjectFile.ShouldBe("projectFile", StringCompareShould.IgnoreCase);
pse.ProjectId.ShouldBe(-1);
pse.TargetNames.ShouldBe("targetNames", StringCompareShould.IgnoreCase);
pse.BuildEventContext.ShouldBe(BuildEventContext.Invalid);
pse.ParentProjectBuildEventContext.ShouldBe(BuildEventContext.Invalid);
}

/// <summary>
/// Verify the BuildEventContext is exercised
/// </summary>
Expand Down
69 changes: 0 additions & 69 deletions src/Framework.UnitTests/LoggerException_Tests.cs

This file was deleted.

62 changes: 0 additions & 62 deletions src/Shared/UnitTests/AssemblyNameEx_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,68 +679,6 @@ public void VerifyReverseVersionComparer()
Assert.True(assemblies[2].Equals(y));
}

[Theory]
[InlineData("System.Xml")]
[InlineData("System.XML, Version=2.0.0.0")]
[InlineData("System.Xml, Culture=de-DE")]
[InlineData("System.Xml, Version=10.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a, Retargetable=Yes")]
[InlineData("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public void VerifyAssemblyNameExSerialization(string assemblyName)
{
AssemblyNameExtension assemblyNameOriginal = new AssemblyNameExtension(assemblyName);
AssemblyNameExtension assemblyNameDeserialized;

byte[] bytes;

using (MemoryStream ms = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(ms, assemblyNameOriginal);

bytes = ms.ToArray();
}

using (MemoryStream ms = new MemoryStream(bytes))
{
BinaryFormatter formatter = new BinaryFormatter();
assemblyNameDeserialized = (AssemblyNameExtension)formatter.Deserialize(ms);
}

assemblyNameDeserialized.ShouldBe(assemblyNameOriginal);
}

[Fact]
public void VerifyAssemblyNameExSerializationWithRemappedFrom()
{
AssemblyNameExtension assemblyNameOriginal = new AssemblyNameExtension("System.Xml, Version=10.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a");
AssemblyNameExtension assemblyRemappedFrom = new AssemblyNameExtension("System.Xml, Version=9.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a");
assemblyRemappedFrom.MarkImmutable();
assemblyNameOriginal.AddRemappedAssemblyName(assemblyRemappedFrom);
assemblyNameOriginal.RemappedFromEnumerator.Count().ShouldBe(1);

AssemblyNameExtension assemblyNameDeserialized;

byte[] bytes;

using (MemoryStream ms = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(ms, assemblyNameOriginal);

bytes = ms.ToArray();
}

using (MemoryStream ms = new MemoryStream(bytes))
{
BinaryFormatter formatter = new BinaryFormatter();
assemblyNameDeserialized = (AssemblyNameExtension)formatter.Deserialize(ms);
}

assemblyNameDeserialized.Equals(assemblyNameOriginal).ShouldBeTrue();
assemblyNameDeserialized.RemappedFromEnumerator.Count().ShouldBe(1);
assemblyNameDeserialized.RemappedFromEnumerator.First().ShouldBe(assemblyRemappedFrom);
}

[Theory]
[InlineData("System.Xml")]
[InlineData("System.XML, Version=2.0.0.0")]
Expand Down
48 changes: 0 additions & 48 deletions src/Shared/UnitTests/CopyOnWriteDictionary_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,53 +192,5 @@ public void CloneWritesNotVisibleToOriginal()
Assert.Equal("1", dictionary["test"]);
Assert.Equal("2", clone["test"]);
}

/// <summary>
/// Serialize basic case
/// </summary>
[Fact]
public void SerializeDeserialize()
{
CopyOnWriteDictionary<string> dictionary = new CopyOnWriteDictionary<string>();
dictionary.Add("Key1", "1");

using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();

formatter.Serialize(stream, dictionary);
stream.Position = 0;

var dictionary2 = (CopyOnWriteDictionary<string>)formatter.Deserialize(stream);

Assert.Equal(dictionary.Count, dictionary2.Count);
Assert.Equal(dictionary.Comparer, dictionary2.Comparer);
Assert.Equal("1", dictionary2["Key1"]);

dictionary2.Add("key2", "2");
}
}

/// <summary>
/// Serialize custom comparer
/// </summary>
[Fact]
public void SerializeDeserialize2()
{
CopyOnWriteDictionary<string> dictionary = new CopyOnWriteDictionary<string>(MSBuildNameIgnoreCaseComparer.Default);

using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();

formatter.Serialize(stream, dictionary);
stream.Position = 0;

CopyOnWriteDictionary<string> deserialized = (CopyOnWriteDictionary<string>)formatter.Deserialize(stream);

deserialized.Count.ShouldBe(dictionary.Count);
deserialized.Comparer.ShouldBeOfType<MSBuildNameIgnoreCaseComparer>();
}
}
}
}

0 comments on commit 9ae833e

Please sign in to comment.