Skip to content

Commit

Permalink
More build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hughbe committed Sep 13, 2023
1 parent 0b4b34b commit 90229fe
Show file tree
Hide file tree
Showing 91 changed files with 484 additions and 226 deletions.
123 changes: 123 additions & 0 deletions src/Microsoft.DotNet.Wpf/tests/UnitTests/WindowsBase.Tests/Helpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Windows;
using System.Windows.Media;
using Xunit.Sdk;

public static class Helpers
{
#pragma warning disable xUnit1013
public static string GetResourcePath(string name) => Path.GetFullPath(Path.Combine("Resources", name));

public static void ExecuteOnDifferentThread(Action action, ApartmentState? state = null)
{
ExceptionDispatchInfo? edi = null;
var t = new Thread(() =>
{
try
{
action();
}
catch (Exception e)
{
edi = ExceptionDispatchInfo.Capture(e);
}
});
if (state is not null)
{
t.SetApartmentState(state.Value);
}
t.Start();
t.Join();

if (edi is not null)
{
edi.Throw();
}
}

public static T ExecuteOnDifferentThread<T>(Func<T> action, ApartmentState? state = null)
{
T? result = default;
ExceptionDispatchInfo? edi = null;
var t = new Thread(() =>
{
try
{
result = action();
}
catch (Exception e)
{
edi = ExceptionDispatchInfo.Capture(e);
}
});
if (state is not null)
{
t.SetApartmentState(state.Value);
}
t.Start();
t.Join();

if (edi is not null)
{
edi.Throw();
throw new Exception("Not reachable.");
}
else
{
return result!;
}
}

public static void AssertEqualRounded(Matrix expected, Matrix actual, int precision = 5)
{
if (expected.Equals(actual))
{
return;
}

try
{
Assert.Equal(expected.M11, actual.M11, precision);
Assert.Equal(expected.M12, actual.M12, precision);
Assert.Equal(expected.M21, actual.M21, precision);
Assert.Equal(expected.M22, actual.M22, precision);
Assert.Equal(expected.OffsetX, actual.OffsetX, precision);
Assert.Equal(expected.OffsetY, actual.OffsetY, precision);
}
catch (Exception)
{
// Throw main AssertException with formatting.
//Assert.Equal(expected, actual);
}
}

public static void AssertEqualRounded(Rect expected, Rect actual, int precision)
{
if (expected.Equals(actual))
{
return;
}

try
{
Assert.Equal(expected.X, actual.X, precision);
Assert.Equal(expected.Y, actual.Y, precision);
Assert.Equal(expected.Width, actual.Width, precision);
Assert.Equal(expected.Height, actual.Height, precision);
}
catch (Exception)
{
// Throw main AssertException with formatting.
Assert.Equal(expected, actual);
}
}
#pragma warning restore xUnit1013
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Windows;

namespace System.Collections.Specialized.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.ComponentModel.Tests;

public class CurrentChangingEventArgsTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Reflection;
using System.Windows;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections;
using System.Windows;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;

namespace System.ComponentModel.Tests;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.ComponentModel.Tests;

public class ItemPropertyInfoTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Windows;

namespace System.ComponentModel.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.ComponentModel.Tests;

public class PropertyFilterAttributeTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections;
using System.Collections.Specialized;
using System.Linq;

namespace System.ComponentModel.Tests;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.ComponentModel.Tests;

public class SortDescriptionTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Windows;

namespace System.Diagnostics.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Security.RightsManagement;

namespace System.IO.Packaging.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Security.Cryptography.X509Certificates;

namespace System.IO.Packaging.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Security.RightsManagement.Tests;

public class ContentGrantTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Security.RightsManagement.Tests;

public class ContentUserTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Security.RightsManagement;

public class CryptoProviderTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Security.RightsManagement.Tests;

public class LocalizedNameDescriptionPairTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Security.RightsManagement.Tests;

public class PublishLicenseTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.Serialization;

namespace System.Security.RightsManagement.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;

namespace System.Security.RightsManagement.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Security.RightsManagement.Tests;

public class UnsignedPublishLicenseTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Security.RightsManagement.Tests;

public class UseLicenseTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Windows.Tests;

public class AttachedPropertyBrowsableForTypeAttributeTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Windows.Tests;

public class AttachedPropertyBrowsableWhenAttributePresentAttributeTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Windows.Tests;

public class BaseCompatibilityPreferencesTests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.ComponentModel;
using System.Windows.Markup;
using System.Windows.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.ComponentModel;
using System.Windows.Markup;
using System.Windows.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.ComponentModel;
using System.Windows.Markup;
using System.Windows.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.ComponentModel;
using System.Windows.Markup;
using System.Windows.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.ComponentModel;
using System.Windows.Markup;
using System.Windows.Tests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.ComponentModel;
using System.Windows.Threading;

Expand Down
Loading

0 comments on commit 90229fe

Please sign in to comment.