Skip to content

Commit deb0faa

Browse files
rolfbjarneGitHub Actions Autoformatter
andauthored
Autoformat cecil-tests.csproj. (#16103)
All other changes should be blank space only. Co-authored-by: GitHub Actions Autoformatter <[email protected]>
1 parent 13e3d85 commit deb0faa

File tree

11 files changed

+69
-83
lines changed

11 files changed

+69
-83
lines changed

.github/workflows/autoformat.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
SRC_DIR=$(pwd)
4444
cd ..
4545
dotnet format "$SRC_DIR/tools/xibuild/xibuild.csproj"
46+
dotnet format whitespace "$SRC_DIR/tests/cecil-tests/cecil-tests.csproj"
4647
# dotnet format "$SRC_DIR/[...]"
4748
# add more projects here...
4849
cd "$SRC_DIR"

tests/cecil-tests/AttributeTest.cs

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,24 @@ public void DoubleAttributedElements (string assemblyPath)
9191
return;
9292
}
9393

94-
var doubleAttributed = new List<string>();
94+
var doubleAttributed = new List<string> ();
9595
foreach (var type in Helper.FilterTypes (assembly, a => HasAnyAvailabilityAttribute (a))) {
9696
var platformCount = new Dictionary<string, int> ();
9797
foreach (var attribute in type.CustomAttributes.Where (a => IsAvailabilityAttribute (a))) {
9898
var kind = FindAvailabilityKind (attribute);
9999
if (kind is not null) {
100-
string key = $"{attribute.AttributeType.Name}-{kind}";
100+
string key = $"{attribute.AttributeType.Name}-{kind}";
101101
if (platformCount.ContainsKey (key)) {
102-
platformCount[key] += 1;
103-
}
104-
else {
105-
platformCount[key] = 1;
102+
platformCount [key] += 1;
103+
} else {
104+
platformCount [key] = 1;
106105
}
107106
}
108107
}
109108
foreach (var (kind, count) in platformCount) {
110109
// AVFoundation.AVMetadataIdentifiers uses an old pattern of a parent
111110
// class and many child classes with constants.
112-
if (type.ToString() == "AVFoundation.AVMetadataIdentifiers") {
111+
if (type.ToString () == "AVFoundation.AVMetadataIdentifiers") {
113112
continue;
114113
}
115114
if (count != 1) {
@@ -133,13 +132,12 @@ void CheckAllPlatformsOnParent (ICustomAttributeProvider item, string fullName,
133132

134133
var myAvailability = GetAvailabilityAttributes (item);
135134
if (!FirstContainsAllOfSecond (myAvailability, parentAvailability)) {
136-
DebugPrint (fullName, parentAvailability, myAvailability);
137-
found.Add (fullName);
135+
DebugPrint (fullName, parentAvailability, myAvailability);
136+
found.Add (fullName);
138137
}
139138
}
140139

141-
public class PlatformClaimInfo
142-
{
140+
public class PlatformClaimInfo {
143141
public HashSet<string> MentionedPlatforms { get; set; } // Mentioned in both Supported and Unsupported contexts
144142
public HashSet<string> ClaimedPlatforms { get; set; } // Mentioned only in Supported contexts
145143

@@ -192,59 +190,58 @@ public void FindSupportedOnElementsThatDoNotExistInThatAssembly ()
192190
foreach (var module in assembly.Modules) {
193191
foreach (var type in module.Types) {
194192
foreach (var member in GetAllTypeMembers (type)) {
195-
var mentionedPlatforms = GetAvailabilityAttributes (member).ToList();
196-
if (mentionedPlatforms.Any()) {
197-
var claimedPlatforms = GetSupportedAvailabilityAttributes (member).ToList();
193+
var mentionedPlatforms = GetAvailabilityAttributes (member).ToList ();
194+
if (mentionedPlatforms.Any ()) {
195+
var claimedPlatforms = GetSupportedAvailabilityAttributes (member).ToList ();
198196
string key = GetMemberLookupKey (member);
199197
if (!harvestedInfo.ContainsKey (key)) {
200-
harvestedInfo[key] = new Dictionary<string, PlatformClaimInfo>();
198+
harvestedInfo [key] = new Dictionary<string, PlatformClaimInfo> ();
201199
}
202200
var claimInfo = new PlatformClaimInfo (mentionedPlatforms, claimedPlatforms);
203-
if (harvestedInfo[key].ContainsKey(currentPlatform)) {
204-
harvestedInfo[key][currentPlatform].UnionWith (claimInfo);
205-
}
206-
else {
207-
harvestedInfo[key][currentPlatform] = claimInfo;
201+
if (harvestedInfo [key].ContainsKey (currentPlatform)) {
202+
harvestedInfo [key] [currentPlatform].UnionWith (claimInfo);
203+
} else {
204+
harvestedInfo [key] [currentPlatform] = claimInfo;
208205
}
209206
}
210207
}
211208
}
212209
}
213210
}
214-
211+
215212
// Now walk every item found above and check two things:
216-
var attributesWereCompiledOut = new List<string>();
217-
var doesNotExistWhereClaimed = new List<string>();
213+
var attributesWereCompiledOut = new List<string> ();
214+
var doesNotExistWhereClaimed = new List<string> ();
218215
foreach (var (member, info) in harvestedInfo) {
219216
// 1. All platforms match in count of mentioned (we did not conditionally compile out attributes)
220-
int expectedPlatformCount = info.First().Value.MentionedPlatforms.Count();
221-
if (info.Any (i => i.Value.MentionedPlatforms.Count() != expectedPlatformCount)) {
222-
if (IgnoreElementsThatDoNotExistInThatAssembly (member)) {
223-
continue;
224-
}
225-
string detailedPlatformBreakdown = string.Join ("\n", info.Select(x => ($"Assembly {x.Key} => {x.Value}")));
226-
string errorMessage = $"{member} did not have the same number of SupportedOSPlatformAttribute in every assembly:\n{detailedPlatformBreakdown}";
227-
attributesWereCompiledOut.Add (errorMessage);
217+
int expectedPlatformCount = info.First ().Value.MentionedPlatforms.Count ();
218+
if (info.Any (i => i.Value.MentionedPlatforms.Count () != expectedPlatformCount)) {
219+
if (IgnoreElementsThatDoNotExistInThatAssembly (member)) {
220+
continue;
221+
}
222+
string detailedPlatformBreakdown = string.Join ("\n", info.Select (x => ($"Assembly {x.Key} => {x.Value}")));
223+
string errorMessage = $"{member} did not have the same number of SupportedOSPlatformAttribute in every assembly:\n{detailedPlatformBreakdown}";
224+
attributesWereCompiledOut.Add (errorMessage);
228225
#if DEBUG
229-
Console.Error.WriteLine (errorMessage);
226+
Console.Error.WriteLine (errorMessage);
230227
#endif
231228
}
232229

233230

234231
// 2. For each supported attribute claim exist, that it exists on that platform
235232
// Since we know each platform claims are now equal, just use the first one
236-
var claimedPlatforms = info.First().Value.ClaimedPlatforms;
233+
var claimedPlatforms = info.First ().Value.ClaimedPlatforms;
237234
foreach (var platform in claimedPlatforms) {
238235
if (!info.ContainsKey (platform)) {
239236
if (IgnoreElementsThatDoNotExistInThatAssembly (member)) {
240237
continue;
241238
}
242-
string detailedPlatformBreakdown = string.Join ("\n", info.Select(x => ($"Assembly {x.Key} => Declares ({string.Join (" ", x.Value)})")));
239+
string detailedPlatformBreakdown = string.Join ("\n", info.Select (x => ($"Assembly {x.Key} => Declares ({string.Join (" ", x.Value)})")));
243240
string errorMessage = $"{member} was not found on {platform} despite being declared supported there.";
244241
doesNotExistWhereClaimed.Add (errorMessage);
245242
#if DEBUG
246243
Console.Error.WriteLine (errorMessage);
247-
#endif
244+
#endif
248245
}
249246
}
250247
}
@@ -260,7 +257,7 @@ static bool IgnoreElementsThatDoNotExistInThatAssembly (string member)
260257
return true;
261258
}
262259
// QuickLook is aliased with QuickLookUI on some platforms
263-
if (member.StartsWith("QuickLook")) {
260+
if (member.StartsWith ("QuickLook")) {
264261
return true;
265262
}
266263
// These two types are defined with non-trivial define magic and one platform doesn't necessarily have
@@ -275,7 +272,7 @@ static bool IgnoreElementsThatDoNotExistInThatAssembly (string member)
275272
return true;
276273
}
277274
// Generator Bug - Protocol inline with different attribute bug
278-
if (member.StartsWith ("SceneKit.SCNLayer") ||
275+
if (member.StartsWith ("SceneKit.SCNLayer") ||
279276
member.StartsWith ("AVFoundation.AVAudioSession")) {
280277
return true;
281278
}
@@ -459,7 +456,7 @@ static string GetMemberLookupKey (IMemberDefinition member)
459456
// Members of xkit and other places conditionally inline and include members in one of two namespaces
460457
// based upon platform assembly. Cludge them to the same key, so we don't mistakenly think members are missing
461458
// from some platforms
462-
return $"{member.DeclaringType.FullName}.{member.Name}".Replace("AppKit", "Kit").Replace("UIKit", "Kit");
459+
return $"{member.DeclaringType.FullName}.{member.Name}".Replace ("AppKit", "Kit").Replace ("UIKit", "Kit");
463460
}
464461

465462
IEnumerable<IMemberDefinition> GetAllTypeMembers (TypeDefinition type)
@@ -525,7 +522,7 @@ void CheckCurrentPlatformIncludedIfAny (ICustomAttributeProvider item, string pl
525522
if (!supportedAttributes.Any (a => FindAvailabilityKind (a) == platformName)) {
526523
#if DEBUG
527524
Console.WriteLine (fullName);
528-
Console.WriteLine (String.Join(" ", supportedAttributes.Select (x => FindAvailabilityKind(x))));
525+
Console.WriteLine (String.Join (" ", supportedAttributes.Select (x => FindAvailabilityKind (x))));
529526
Console.WriteLine (platformName);
530527
#endif
531528
found.Add (fullName);
@@ -617,7 +614,7 @@ IEnumerable<string> GetAvailabilityAttributesCore (IEnumerable<CustomAttribute>
617614

618615
bool HasAnyAvailabilityAttribute (ICustomAttributeProvider provider) => provider.CustomAttributes.Any (a => IsAvailabilityAttribute (a));
619616
bool HasAnySupportedAttribute (ICustomAttributeProvider provider) => provider.CustomAttributes.Any (a => IsSupportedAttribute (a));
620-
617+
621618
bool IsAvailabilityAttribute (CustomAttribute attribute) => IsSupportedAttribute (attribute) || attribute.AttributeType.Name == "UnsupportedOSPlatformAttribute";
622619
bool IsSupportedAttribute (CustomAttribute attribute) => attribute.AttributeType.Name == "SupportedOSPlatformAttribute";
623620
}

tests/cecil-tests/GenericPInvokes.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ string ListOfFailingGenerics (IEnumerable<MethodAndResult> methodAndResults)
9797
{
9898
var list = new StringBuilder ();
9999
foreach (var mar in methodAndResults) {
100-
list.Append ("\n\"").Append (mar.Method.FullName).Append("\" : ");
100+
list.Append ("\n\"").Append (mar.Method.FullName).Append ("\" : ");
101101
switch (mar.Result) {
102102
case GenericCheckResult.ContainsGenerics:
103103
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 @@ IEnumerable<MethodDefinition> AllSetupBlocks (AssemblyDefinition assembly)
151151
if (method.Body is null)
152152
return false;
153153
return method.Body.Instructions.Any (IsCallToSetupBlockUnsafe);
154-
});
154+
});
155155
}
156156

157157
static bool IsCallToSetupBlockUnsafe (Instruction instr)
@@ -160,7 +160,8 @@ static bool IsCallToSetupBlockUnsafe (Instruction instr)
160160
instr.Operand.ToString () == "System.Void ObjCRuntime.BlockLiteral::SetupBlockUnsafe(System.Delegate,System.Delegate)";
161161
}
162162

163-
static bool IsCall (Instruction instr) {
163+
static bool IsCall (Instruction instr)
164+
{
164165
return instr.OpCode == OpCodes.Call ||
165166
instr.OpCode == OpCodes.Calli;
166167
}
@@ -229,7 +230,7 @@ static bool IsBranch (Instruction instr)
229230

230231
static TypeReference GetLastArgType (MethodDefinition method, Instruction instr)
231232
{
232-
var paramDef = GetOperandType(method, instr);
233+
var paramDef = GetOperandType (method, instr);
233234
if (paramDef is null) {
234235
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!");
235236
}

tests/cecil-tests/Helper.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public static IEnumerable TaskAssemblies {
198198
if (Configuration.include_ios)
199199
yield return CreateTestFixtureDataFromPath (Path.Combine (Configuration.SdkRootXI, "lib", "msbuild", "iOS", "Xamarin.iOS.Tasks.dll"));
200200
if (Configuration.include_mac)
201-
yield return CreateTestFixtureDataFromPath (Path.Combine (Configuration.SdkRootXM, "lib", "msbuild", "Xamarin.Mac.Tasks.dll"));
201+
yield return CreateTestFixtureDataFromPath (Path.Combine (Configuration.SdkRootXM, "lib", "msbuild", "Xamarin.Mac.Tasks.dll"));
202202
}
203203
}
204204

@@ -210,10 +210,9 @@ static TestFixtureData CreateTestFixtureDataFromPath (string path)
210210
}
211211
}
212212

213-
public static class CompatExtensions
214-
{
213+
public static class CompatExtensions {
215214
// cecil-tests is not NET5 yet, this is required to foreach over a dictionary
216-
public static void Deconstruct<T1, T2>(this KeyValuePair<T1, T2> tuple, out T1 key, out T2 value)
215+
public static void Deconstruct<T1, T2> (this KeyValuePair<T1, T2> tuple, out T1 key, out T2 value)
217216
{
218217
key = tuple.Key;
219218
value = tuple.Value;

tests/cecil-tests/Test.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void IdentifyBackingFieldAssignation (string assemblyPath)
5050
}
5151
}
5252

53-
[TestCaseSource (typeof (Helper), nameof (Helper.PlatformAssemblies))]
53+
[TestCaseSource (typeof (Helper), nameof (Helper.PlatformAssemblies))]
5454
[TestCaseSource (typeof (Helper), nameof (Helper.NetPlatformImplementationAssemblies))]
5555
// ref: https://github.com/xamarin/xamarin-macios/issues/8249
5656
public void EnsureUIThreadOnInit (string assemblyPath)

tests/common/Configuration.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
#nullable disable // until we get around to fixing this file
1313

14-
namespace Xamarin.Tests
15-
{
16-
static partial class Configuration
17-
{
14+
namespace Xamarin.Tests {
15+
static partial class Configuration {
1816
public const string XI_ProductName = "MonoTouch";
1917
public const string XM_ProductName = "Xamarin.Mac";
2018

@@ -89,7 +87,7 @@ public static string XcodeLocation {
8987
}
9088

9189
public static string IOS_DESTDIR {
92-
get { return ios_destdir; }
90+
get { return ios_destdir; }
9391
}
9492

9593
public static string MAC_DESTDIR {
@@ -121,8 +119,7 @@ public static string GetOldXcodeRoot (Version min_version = null)
121119
if (with_versions.Count == 0)
122120
return null;
123121

124-
with_versions.Sort ((x, y) =>
125-
{
122+
with_versions.Sort ((x, y) => {
126123
if (x.Item1 > y.Item1)
127124
return -1;
128125
else if (x.Item1 < y.Item1)
@@ -354,7 +351,7 @@ public static bool TryGetRootPath (out string rootPath)
354351
return false;
355352
}
356353
}
357-
354+
358355
static string TestAssemblyDirectory {
359356
get {
360357
return TestContext.CurrentContext.WorkDirectory;
@@ -417,15 +414,15 @@ public static string SdkBinDir {
417414

418415
public static string TargetDirectoryXI {
419416
get {
420-
if (UseSystem)
417+
if (UseSystem)
421418
return "/";
422419
return make_config ["IOS_DESTDIR"];
423420
}
424421
}
425422

426423
public static string TargetDirectoryXM {
427424
get {
428-
if (UseSystem)
425+
if (UseSystem)
429426
return "/";
430427
return make_config ["MAC_DESTDIR"];
431428
}
@@ -450,7 +447,7 @@ public static string SdkRoot {
450447
static string GetRefNuGetName (TargetFramework targetFramework) => GetRefNuGetName (targetFramework.Platform);
451448

452449
static string GetRefNuGetName (ApplePlatform platform)
453-
{
450+
{
454451
switch (platform) {
455452
case ApplePlatform.iOS:
456453
return "Microsoft.iOS.Ref";
@@ -747,7 +744,7 @@ public static ApplePlatform GetPlatform (string assemblyName, bool isDotNet)
747744
throw new NotSupportedException ($"Unknown assembly: {assemblyName}");
748745
}
749746
}
750-
}
747+
}
751748

752749
public static string GetBaseLibrary (TargetFramework targetFramework)
753750
{
@@ -901,7 +898,7 @@ public static string GetCompiler (Profile profile, IList<string> args)
901898
return "/Library/Frameworks/Mono.framework/Commands/csc";
902899
}
903900
#endif // !XAMMAC_TESTS
904-
901+
905902
public static IEnumerable<ApplePlatform> GetIncludedPlatforms (bool dotnet)
906903
{
907904
if (include_ios)
@@ -1021,7 +1018,7 @@ public static void SetBuildVariables (ApplePlatform platform, ref Dictionary<str
10211018
environment ["MD_APPLE_SDK_ROOT"] = Path.GetDirectoryName (Path.GetDirectoryName (xcode_root));
10221019
environment ["TargetFrameworkFallbackSearchPaths"] = Path.Combine (rootDirectory, "Library", "Frameworks", "Mono.framework", "External", "xbuild-frameworks");
10231020
environment ["MSBuildExtensionsPathFallbackPathsOverride"] = Path.Combine (rootDirectory, "Library", "Frameworks", "Mono.framework", "External", "xbuild");
1024-
1021+
10251022
// This is set by `dotnet test` and can cause building legacy projects to fail to build with:
10261023
// Microsoft.NET.Build.Extensions.ConflictResolution.targets(30,5):
10271024
// error MSB4062: The "ResolvePackageFileConflicts" task could not be loaded from the assembly Microsoft.NET.Build.Extensions.Tasks.dll.
@@ -1063,7 +1060,7 @@ public static void IgnoreIfIgnoredPlatform (ApplePlatform platform)
10631060
if (!include_dotnet_watchos)
10641061
Assert.Ignore ("watchOS is not included in this build");
10651062
#endif
1066-
1063+
10671064
break;
10681065
case ApplePlatform.MacOSX:
10691066
if (!include_mac)

tests/common/ExecutionHelper.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010

1111
#nullable disable // until we get around to fixing this file
1212

13-
namespace Xamarin.Tests
14-
{
15-
class XBuild
16-
{
13+
namespace Xamarin.Tests {
14+
class XBuild {
1715
public static string ToolPath {
18-
get
19-
{
16+
get {
2017
return Configuration.XIBuildPath;
2118
}
2219
}

tests/common/Profile.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
22
using Xamarin.Utils;
33

4-
namespace Xamarin.Tests
5-
{
6-
public enum Profile
7-
{
4+
namespace Xamarin.Tests {
5+
public enum Profile {
86
None,
97
iOS,
108
tvOS,

tests/mtouch/Cache.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
#nullable enable
77

8-
namespace Xamarin
9-
{
8+
namespace Xamarin {
109
// A class that creates temporary directories next to the test assembly, and cleans the output on startup
1110
// Advantages:
1211
// * The temporary directories are automatically cleaned on Wrench (unlike /tmp, which isn't)

0 commit comments

Comments
 (0)