Autoformat cecil-tests.csproj. (#16103)
All other changes should be blank space only. Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
This commit is contained in:
Родитель
13e3d85a41
Коммит
deb0faa4f2
|
@ -43,6 +43,7 @@ jobs:
|
|||
SRC_DIR=$(pwd)
|
||||
cd ..
|
||||
dotnet format "$SRC_DIR/tools/xibuild/xibuild.csproj"
|
||||
dotnet format whitespace "$SRC_DIR/tests/cecil-tests/cecil-tests.csproj"
|
||||
# dotnet format "$SRC_DIR/[...]"
|
||||
# add more projects here...
|
||||
cd "$SRC_DIR"
|
||||
|
|
|
@ -91,25 +91,24 @@ namespace Cecil.Tests {
|
|||
return;
|
||||
}
|
||||
|
||||
var doubleAttributed = new List<string>();
|
||||
var doubleAttributed = new List<string> ();
|
||||
foreach (var type in Helper.FilterTypes (assembly, a => HasAnyAvailabilityAttribute (a))) {
|
||||
var platformCount = new Dictionary<string, int> ();
|
||||
foreach (var attribute in type.CustomAttributes.Where (a => IsAvailabilityAttribute (a))) {
|
||||
var kind = FindAvailabilityKind (attribute);
|
||||
if (kind is not null) {
|
||||
string key = $"{attribute.AttributeType.Name}-{kind}";
|
||||
string key = $"{attribute.AttributeType.Name}-{kind}";
|
||||
if (platformCount.ContainsKey (key)) {
|
||||
platformCount[key] += 1;
|
||||
}
|
||||
else {
|
||||
platformCount[key] = 1;
|
||||
platformCount [key] += 1;
|
||||
} else {
|
||||
platformCount [key] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var (kind, count) in platformCount) {
|
||||
// AVFoundation.AVMetadataIdentifiers uses an old pattern of a parent
|
||||
// class and many child classes with constants.
|
||||
if (type.ToString() == "AVFoundation.AVMetadataIdentifiers") {
|
||||
if (type.ToString () == "AVFoundation.AVMetadataIdentifiers") {
|
||||
continue;
|
||||
}
|
||||
if (count != 1) {
|
||||
|
@ -133,13 +132,12 @@ namespace Cecil.Tests {
|
|||
|
||||
var myAvailability = GetAvailabilityAttributes (item);
|
||||
if (!FirstContainsAllOfSecond (myAvailability, parentAvailability)) {
|
||||
DebugPrint (fullName, parentAvailability, myAvailability);
|
||||
found.Add (fullName);
|
||||
DebugPrint (fullName, parentAvailability, myAvailability);
|
||||
found.Add (fullName);
|
||||
}
|
||||
}
|
||||
|
||||
public class PlatformClaimInfo
|
||||
{
|
||||
public class PlatformClaimInfo {
|
||||
public HashSet<string> MentionedPlatforms { get; set; } // Mentioned in both Supported and Unsupported contexts
|
||||
public HashSet<string> ClaimedPlatforms { get; set; } // Mentioned only in Supported contexts
|
||||
|
||||
|
@ -192,59 +190,58 @@ namespace Cecil.Tests {
|
|||
foreach (var module in assembly.Modules) {
|
||||
foreach (var type in module.Types) {
|
||||
foreach (var member in GetAllTypeMembers (type)) {
|
||||
var mentionedPlatforms = GetAvailabilityAttributes (member).ToList();
|
||||
if (mentionedPlatforms.Any()) {
|
||||
var claimedPlatforms = GetSupportedAvailabilityAttributes (member).ToList();
|
||||
var mentionedPlatforms = GetAvailabilityAttributes (member).ToList ();
|
||||
if (mentionedPlatforms.Any ()) {
|
||||
var claimedPlatforms = GetSupportedAvailabilityAttributes (member).ToList ();
|
||||
string key = GetMemberLookupKey (member);
|
||||
if (!harvestedInfo.ContainsKey (key)) {
|
||||
harvestedInfo[key] = new Dictionary<string, PlatformClaimInfo>();
|
||||
harvestedInfo [key] = new Dictionary<string, PlatformClaimInfo> ();
|
||||
}
|
||||
var claimInfo = new PlatformClaimInfo (mentionedPlatforms, claimedPlatforms);
|
||||
if (harvestedInfo[key].ContainsKey(currentPlatform)) {
|
||||
harvestedInfo[key][currentPlatform].UnionWith (claimInfo);
|
||||
}
|
||||
else {
|
||||
harvestedInfo[key][currentPlatform] = claimInfo;
|
||||
if (harvestedInfo [key].ContainsKey (currentPlatform)) {
|
||||
harvestedInfo [key] [currentPlatform].UnionWith (claimInfo);
|
||||
} else {
|
||||
harvestedInfo [key] [currentPlatform] = claimInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now walk every item found above and check two things:
|
||||
var attributesWereCompiledOut = new List<string>();
|
||||
var doesNotExistWhereClaimed = new List<string>();
|
||||
var attributesWereCompiledOut = new List<string> ();
|
||||
var doesNotExistWhereClaimed = new List<string> ();
|
||||
foreach (var (member, info) in harvestedInfo) {
|
||||
// 1. All platforms match in count of mentioned (we did not conditionally compile out attributes)
|
||||
int expectedPlatformCount = info.First().Value.MentionedPlatforms.Count();
|
||||
if (info.Any (i => i.Value.MentionedPlatforms.Count() != expectedPlatformCount)) {
|
||||
if (IgnoreElementsThatDoNotExistInThatAssembly (member)) {
|
||||
continue;
|
||||
}
|
||||
string detailedPlatformBreakdown = string.Join ("\n", info.Select(x => ($"Assembly {x.Key} => {x.Value}")));
|
||||
string errorMessage = $"{member} did not have the same number of SupportedOSPlatformAttribute in every assembly:\n{detailedPlatformBreakdown}";
|
||||
attributesWereCompiledOut.Add (errorMessage);
|
||||
int expectedPlatformCount = info.First ().Value.MentionedPlatforms.Count ();
|
||||
if (info.Any (i => i.Value.MentionedPlatforms.Count () != expectedPlatformCount)) {
|
||||
if (IgnoreElementsThatDoNotExistInThatAssembly (member)) {
|
||||
continue;
|
||||
}
|
||||
string detailedPlatformBreakdown = string.Join ("\n", info.Select (x => ($"Assembly {x.Key} => {x.Value}")));
|
||||
string errorMessage = $"{member} did not have the same number of SupportedOSPlatformAttribute in every assembly:\n{detailedPlatformBreakdown}";
|
||||
attributesWereCompiledOut.Add (errorMessage);
|
||||
#if DEBUG
|
||||
Console.Error.WriteLine (errorMessage);
|
||||
Console.Error.WriteLine (errorMessage);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// 2. For each supported attribute claim exist, that it exists on that platform
|
||||
// Since we know each platform claims are now equal, just use the first one
|
||||
var claimedPlatforms = info.First().Value.ClaimedPlatforms;
|
||||
var claimedPlatforms = info.First ().Value.ClaimedPlatforms;
|
||||
foreach (var platform in claimedPlatforms) {
|
||||
if (!info.ContainsKey (platform)) {
|
||||
if (IgnoreElementsThatDoNotExistInThatAssembly (member)) {
|
||||
continue;
|
||||
}
|
||||
string detailedPlatformBreakdown = string.Join ("\n", info.Select(x => ($"Assembly {x.Key} => Declares ({string.Join (" ", x.Value)})")));
|
||||
string detailedPlatformBreakdown = string.Join ("\n", info.Select (x => ($"Assembly {x.Key} => Declares ({string.Join (" ", x.Value)})")));
|
||||
string errorMessage = $"{member} was not found on {platform} despite being declared supported there.";
|
||||
doesNotExistWhereClaimed.Add (errorMessage);
|
||||
#if DEBUG
|
||||
Console.Error.WriteLine (errorMessage);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +257,7 @@ namespace Cecil.Tests {
|
|||
return true;
|
||||
}
|
||||
// QuickLook is aliased with QuickLookUI on some platforms
|
||||
if (member.StartsWith("QuickLook")) {
|
||||
if (member.StartsWith ("QuickLook")) {
|
||||
return true;
|
||||
}
|
||||
// These two types are defined with non-trivial define magic and one platform doesn't necessarily have
|
||||
|
@ -275,7 +272,7 @@ namespace Cecil.Tests {
|
|||
return true;
|
||||
}
|
||||
// Generator Bug - Protocol inline with different attribute bug
|
||||
if (member.StartsWith ("SceneKit.SCNLayer") ||
|
||||
if (member.StartsWith ("SceneKit.SCNLayer") ||
|
||||
member.StartsWith ("AVFoundation.AVAudioSession")) {
|
||||
return true;
|
||||
}
|
||||
|
@ -459,7 +456,7 @@ namespace Cecil.Tests {
|
|||
// Members of xkit and other places conditionally inline and include members in one of two namespaces
|
||||
// based upon platform assembly. Cludge them to the same key, so we don't mistakenly think members are missing
|
||||
// from some platforms
|
||||
return $"{member.DeclaringType.FullName}.{member.Name}".Replace("AppKit", "Kit").Replace("UIKit", "Kit");
|
||||
return $"{member.DeclaringType.FullName}.{member.Name}".Replace ("AppKit", "Kit").Replace ("UIKit", "Kit");
|
||||
}
|
||||
|
||||
IEnumerable<IMemberDefinition> GetAllTypeMembers (TypeDefinition type)
|
||||
|
@ -525,7 +522,7 @@ namespace Cecil.Tests {
|
|||
if (!supportedAttributes.Any (a => FindAvailabilityKind (a) == platformName)) {
|
||||
#if DEBUG
|
||||
Console.WriteLine (fullName);
|
||||
Console.WriteLine (String.Join(" ", supportedAttributes.Select (x => FindAvailabilityKind(x))));
|
||||
Console.WriteLine (String.Join (" ", supportedAttributes.Select (x => FindAvailabilityKind (x))));
|
||||
Console.WriteLine (platformName);
|
||||
#endif
|
||||
found.Add (fullName);
|
||||
|
@ -617,7 +614,7 @@ namespace Cecil.Tests {
|
|||
|
||||
bool HasAnyAvailabilityAttribute (ICustomAttributeProvider provider) => provider.CustomAttributes.Any (a => IsAvailabilityAttribute (a));
|
||||
bool HasAnySupportedAttribute (ICustomAttributeProvider provider) => provider.CustomAttributes.Any (a => IsSupportedAttribute (a));
|
||||
|
||||
|
||||
bool IsAvailabilityAttribute (CustomAttribute attribute) => IsSupportedAttribute (attribute) || attribute.AttributeType.Name == "UnsupportedOSPlatformAttribute";
|
||||
bool IsSupportedAttribute (CustomAttribute attribute) => attribute.AttributeType.Name == "SupportedOSPlatformAttribute";
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Cecil.Tests {
|
|||
{
|
||||
var list = new StringBuilder ();
|
||||
foreach (var mar in methodAndResults) {
|
||||
list.Append ("\n\"").Append (mar.Method.FullName).Append("\" : ");
|
||||
list.Append ("\n\"").Append (mar.Method.FullName).Append ("\" : ");
|
||||
switch (mar.Result) {
|
||||
case GenericCheckResult.ContainsGenerics:
|
||||
list.Append ("method contains a generic argument for the first arg of SetupBlockUnsafe. This is problematic in .NET 7 and above.");
|
||||
|
@ -151,7 +151,7 @@ namespace Cecil.Tests {
|
|||
if (method.Body is null)
|
||||
return false;
|
||||
return method.Body.Instructions.Any (IsCallToSetupBlockUnsafe);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static bool IsCallToSetupBlockUnsafe (Instruction instr)
|
||||
|
@ -160,7 +160,8 @@ namespace Cecil.Tests {
|
|||
instr.Operand.ToString () == "System.Void ObjCRuntime.BlockLiteral::SetupBlockUnsafe(System.Delegate,System.Delegate)";
|
||||
}
|
||||
|
||||
static bool IsCall (Instruction instr) {
|
||||
static bool IsCall (Instruction instr)
|
||||
{
|
||||
return instr.OpCode == OpCodes.Call ||
|
||||
instr.OpCode == OpCodes.Calli;
|
||||
}
|
||||
|
@ -229,7 +230,7 @@ namespace Cecil.Tests {
|
|||
|
||||
static TypeReference GetLastArgType (MethodDefinition method, Instruction instr)
|
||||
{
|
||||
var paramDef = GetOperandType(method, instr);
|
||||
var paramDef = GetOperandType (method, instr);
|
||||
if (paramDef is null) {
|
||||
throw new NotImplementedException ($"Last instruction before call to SetupBlockUnsafe ({instr.ToString ()}) was not a Ldfld, Ldarg or Ldloc - this is quite unexpected - something's changed in the code base!");
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace Cecil.Tests {
|
|||
if (Configuration.include_ios)
|
||||
yield return CreateTestFixtureDataFromPath (Path.Combine (Configuration.SdkRootXI, "lib", "msbuild", "iOS", "Xamarin.iOS.Tasks.dll"));
|
||||
if (Configuration.include_mac)
|
||||
yield return CreateTestFixtureDataFromPath (Path.Combine (Configuration.SdkRootXM, "lib", "msbuild", "Xamarin.Mac.Tasks.dll"));
|
||||
yield return CreateTestFixtureDataFromPath (Path.Combine (Configuration.SdkRootXM, "lib", "msbuild", "Xamarin.Mac.Tasks.dll"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,10 +210,9 @@ namespace Cecil.Tests {
|
|||
}
|
||||
}
|
||||
|
||||
public static class CompatExtensions
|
||||
{
|
||||
public static class CompatExtensions {
|
||||
// cecil-tests is not NET5 yet, this is required to foreach over a dictionary
|
||||
public static void Deconstruct<T1, T2>(this KeyValuePair<T1, T2> tuple, out T1 key, out T2 value)
|
||||
public static void Deconstruct<T1, T2> (this KeyValuePair<T1, T2> tuple, out T1 key, out T2 value)
|
||||
{
|
||||
key = tuple.Key;
|
||||
value = tuple.Value;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Cecil.Tests {
|
|||
}
|
||||
}
|
||||
|
||||
[TestCaseSource (typeof (Helper), nameof (Helper.PlatformAssemblies))]
|
||||
[TestCaseSource (typeof (Helper), nameof (Helper.PlatformAssemblies))]
|
||||
[TestCaseSource (typeof (Helper), nameof (Helper.NetPlatformImplementationAssemblies))]
|
||||
// ref: https://github.com/xamarin/xamarin-macios/issues/8249
|
||||
public void EnsureUIThreadOnInit (string assemblyPath)
|
||||
|
|
|
@ -11,10 +11,8 @@ using Xamarin.Utils;
|
|||
|
||||
#nullable disable // until we get around to fixing this file
|
||||
|
||||
namespace Xamarin.Tests
|
||||
{
|
||||
static partial class Configuration
|
||||
{
|
||||
namespace Xamarin.Tests {
|
||||
static partial class Configuration {
|
||||
public const string XI_ProductName = "MonoTouch";
|
||||
public const string XM_ProductName = "Xamarin.Mac";
|
||||
|
||||
|
@ -89,7 +87,7 @@ namespace Xamarin.Tests
|
|||
}
|
||||
|
||||
public static string IOS_DESTDIR {
|
||||
get { return ios_destdir; }
|
||||
get { return ios_destdir; }
|
||||
}
|
||||
|
||||
public static string MAC_DESTDIR {
|
||||
|
@ -121,8 +119,7 @@ namespace Xamarin.Tests
|
|||
if (with_versions.Count == 0)
|
||||
return null;
|
||||
|
||||
with_versions.Sort ((x, y) =>
|
||||
{
|
||||
with_versions.Sort ((x, y) => {
|
||||
if (x.Item1 > y.Item1)
|
||||
return -1;
|
||||
else if (x.Item1 < y.Item1)
|
||||
|
@ -354,7 +351,7 @@ namespace Xamarin.Tests
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static string TestAssemblyDirectory {
|
||||
get {
|
||||
return TestContext.CurrentContext.WorkDirectory;
|
||||
|
@ -417,7 +414,7 @@ namespace Xamarin.Tests
|
|||
|
||||
public static string TargetDirectoryXI {
|
||||
get {
|
||||
if (UseSystem)
|
||||
if (UseSystem)
|
||||
return "/";
|
||||
return make_config ["IOS_DESTDIR"];
|
||||
}
|
||||
|
@ -425,7 +422,7 @@ namespace Xamarin.Tests
|
|||
|
||||
public static string TargetDirectoryXM {
|
||||
get {
|
||||
if (UseSystem)
|
||||
if (UseSystem)
|
||||
return "/";
|
||||
return make_config ["MAC_DESTDIR"];
|
||||
}
|
||||
|
@ -450,7 +447,7 @@ namespace Xamarin.Tests
|
|||
static string GetRefNuGetName (TargetFramework targetFramework) => GetRefNuGetName (targetFramework.Platform);
|
||||
|
||||
static string GetRefNuGetName (ApplePlatform platform)
|
||||
{
|
||||
{
|
||||
switch (platform) {
|
||||
case ApplePlatform.iOS:
|
||||
return "Microsoft.iOS.Ref";
|
||||
|
@ -747,7 +744,7 @@ namespace Xamarin.Tests
|
|||
throw new NotSupportedException ($"Unknown assembly: {assemblyName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetBaseLibrary (TargetFramework targetFramework)
|
||||
{
|
||||
|
@ -901,7 +898,7 @@ namespace Xamarin.Tests
|
|||
return "/Library/Frameworks/Mono.framework/Commands/csc";
|
||||
}
|
||||
#endif // !XAMMAC_TESTS
|
||||
|
||||
|
||||
public static IEnumerable<ApplePlatform> GetIncludedPlatforms (bool dotnet)
|
||||
{
|
||||
if (include_ios)
|
||||
|
@ -1021,7 +1018,7 @@ namespace Xamarin.Tests
|
|||
environment ["MD_APPLE_SDK_ROOT"] = Path.GetDirectoryName (Path.GetDirectoryName (xcode_root));
|
||||
environment ["TargetFrameworkFallbackSearchPaths"] = Path.Combine (rootDirectory, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks");
|
||||
environment ["MSBuildExtensionsPathFallbackPathsOverride"] = Path.Combine (rootDirectory, "Library", "Frameworks", "Mono.framework", "External", "xbuild");
|
||||
|
||||
|
||||
// This is set by `dotnet test` and can cause building legacy projects to fail to build with:
|
||||
// Microsoft.NET.Build.Extensions.ConflictResolution.targets(30,5):
|
||||
// error MSB4062: The "ResolvePackageFileConflicts" task could not be loaded from the assembly Microsoft.NET.Build.Extensions.Tasks.dll.
|
||||
|
@ -1063,7 +1060,7 @@ namespace Xamarin.Tests
|
|||
if (!include_dotnet_watchos)
|
||||
Assert.Ignore ("watchOS is not included in this build");
|
||||
#endif
|
||||
|
||||
|
||||
break;
|
||||
case ApplePlatform.MacOSX:
|
||||
if (!include_mac)
|
||||
|
|
|
@ -10,13 +10,10 @@ using Xamarin.Utils;
|
|||
|
||||
#nullable disable // until we get around to fixing this file
|
||||
|
||||
namespace Xamarin.Tests
|
||||
{
|
||||
class XBuild
|
||||
{
|
||||
namespace Xamarin.Tests {
|
||||
class XBuild {
|
||||
public static string ToolPath {
|
||||
get
|
||||
{
|
||||
get {
|
||||
return Configuration.XIBuildPath;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
using System;
|
||||
using Xamarin.Utils;
|
||||
|
||||
namespace Xamarin.Tests
|
||||
{
|
||||
public enum Profile
|
||||
{
|
||||
namespace Xamarin.Tests {
|
||||
public enum Profile {
|
||||
None,
|
||||
iOS,
|
||||
tvOS,
|
||||
|
|
|
@ -5,8 +5,7 @@ using System.Threading;
|
|||
|
||||
#nullable enable
|
||||
|
||||
namespace Xamarin
|
||||
{
|
||||
namespace Xamarin {
|
||||
// A class that creates temporary directories next to the test assembly, and cleans the output on startup
|
||||
// Advantages:
|
||||
// * The temporary directories are automatically cleaned on Wrench (unlike /tmp, which isn't)
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
//
|
||||
// Copyright 2020 Microsoft Corp. All Rights Reserved.
|
||||
|
||||
namespace Xamarin.Utils
|
||||
{
|
||||
namespace Xamarin.Utils {
|
||||
public enum ApplePlatform {
|
||||
None,
|
||||
MacOSX,
|
||||
|
|
|
@ -12,10 +12,8 @@ using System.Linq;
|
|||
|
||||
#nullable disable // until we get around to fixing this file
|
||||
|
||||
namespace Xamarin.Utils
|
||||
{
|
||||
public struct TargetFramework : IEquatable<TargetFramework>
|
||||
{
|
||||
namespace Xamarin.Utils {
|
||||
public struct TargetFramework : IEquatable<TargetFramework> {
|
||||
const string TFMVersion = "6.0";
|
||||
public const string DotNet_iOS_String = ".NETCoreApp,Version=" + TFMVersion + ",Profile=ios"; // Short form: netX.Y-ios
|
||||
public const string DotNet_tvOS_String = ".NETCoreApp,Version=" + TFMVersion + ",Profile=tvos"; // Short form: netX.Y-tvos
|
||||
|
@ -191,7 +189,7 @@ namespace Xamarin.Utils
|
|||
|
||||
public override bool Equals (object obj)
|
||||
{
|
||||
return obj is TargetFramework ? Equals ((TargetFramework)obj) : false;
|
||||
return obj is TargetFramework ? Equals ((TargetFramework) obj) : false;
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
|
|
Загрузка…
Ссылка в новой задаче