Skip to content

Commit

Permalink
Auto-format source code
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions Autoformatter committed Jan 21, 2025
1 parent 9cf6c25 commit 9c2815b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public IEnumerable<PlatformAvailability> PlatformAvailabilities {
}
}
}

/// <summary>
/// Returns the PlatformAvailability for the given platform. If we did not have a builder for the
/// platform, a new one is created and added to the dictionary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public static void GetInheritance (
parents = parentsBuilder.ToImmutable ();
interfaces = [.. interfacesSet];
}

/// <summary>
/// Returns the symbol availability taking into account the parent symbols availability.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static SymbolAvailability GetAvailabilityForSymbol (this ISymbol symbol)

return builder.ToImmutable ();
}

public static bool IsSmartEnum (this ITypeSymbol symbol)
{
// a type is a smart enum if its type is a enum one AND it was decorated with the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static class XamarinAvailabilityData {
{ AttributesNames.NoMacAttribute, ApplePlatform.MacOSX },
{ AttributesNames.NoMacCatalystAttribute, ApplePlatform.MacCatalyst },
};

public static bool TryParseSupportedOSData (string attributeName, AttributeData attributeData,
[NotNullWhen (true)] out SupportedOSPlatformData? data)
{
Expand All @@ -32,24 +32,24 @@ public static bool TryParseSupportedOSData (string attributeName, AttributeData
// not a supported attribute
return false;
}

var count = attributeData.ConstructorArguments.Length;
int major = 0;
int? minor = null;
int? subminor = null;

// custom marshal directive values

switch (count) {
case 1:
major = (byte) attributeData.ConstructorArguments [0].Value!;
break;
case 2:
major = (byte) attributeData.ConstructorArguments [0].Value!;
major = (byte) attributeData.ConstructorArguments [0].Value!;
minor = (byte) attributeData.ConstructorArguments [1].Value!;
break;
case 3:
major = (byte) attributeData.ConstructorArguments [0].Value!;
major = (byte) attributeData.ConstructorArguments [0].Value!;
minor = (byte) attributeData.ConstructorArguments [1].Value!;
subminor = (byte) attributeData.ConstructorArguments [2].Value!;
break;
Expand All @@ -59,9 +59,9 @@ public static bool TryParseSupportedOSData (string attributeName, AttributeData
}

data = (major, minor, subminor) switch {
(_, null, null) => new(platform, new($"{major}")),
(_, not null, null) => new(platform, new(major, minor.Value)),
(_,not null, not null) => new(platform, new(major, minor.Value, subminor.Value)),
(_, null, null) => new (platform, new ($"{major}")),
(_, not null, null) => new (platform, new (major, minor.Value)),
(_, not null, not null) => new (platform, new (major, minor.Value, subminor.Value)),
_ => throw new ArgumentOutOfRangeException ("Could not parse the version")
};
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static partial class TypeSymbolExtensions {
ApplePlatform.MacOSX,
ApplePlatform.MacCatalyst
];

/// <summary>
/// Return the symbol availability WITHOUT taking into account the parent symbols availability.
/// </summary>
Expand All @@ -40,25 +40,25 @@ internal static SymbolAvailability GetAvailabilityForSymbol (this ISymbol symbol
var attrName = attributeData.AttributeClass?.ToDisplayString ();
if (string.IsNullOrEmpty (attrName))
continue;

if (XamarinAvailabilityData.TryParseSupportedOSData (attrName, attributeData, out var availabilityData)) {
builder.Add (availabilityData.Value);
}

if (XamarinAvailabilityData.TryParseUnsupportedOSData (attrName, attributeData,
out var unsupportedOsPlatformData)) {
out var unsupportedOsPlatformData)) {
builder.Add (unsupportedOsPlatformData.Value);
}
}

// if a platform was not ignore or had a specific version, then it is supported, loop over what we got
// and add the missing platforms with the default version
var supportedPlatforms = builder.PlatformAvailabilities.ToArray ()
.Select (a => a.Platform);

// add data to all not added platforms
foreach (var platform in allSupportedPlatforms.Except (supportedPlatforms)) {
builder.Add (new SupportedOSPlatformData(platform, new Version()));
builder.Add (new SupportedOSPlatformData (platform, new Version ()));
}

return builder.ToImmutable ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ interface UIFeedbackGenerator : UIInteraction {
void Prepare ();
}
";

builder.Add (new SupportedOSPlatformData ("ios"));
builder.Add (new SupportedOSPlatformData("tvos"));
builder.Add (new SupportedOSPlatformData ("tvos"));
builder.Add (new SupportedOSPlatformData ("macos"));
builder.Add (new SupportedOSPlatformData ("maccatalyst13.1"));
yield return [(Source: onePlatformSpecificVersion, Path: path), builder.ToImmutable ()];
Expand All @@ -110,10 +110,10 @@ interface UIFeedbackGenerator : UIInteraction {
}
";

builder.Add (new UnsupportedOSPlatformData("ios"));
builder.Add (new UnsupportedOSPlatformData("tvos"));
builder.Add (new UnsupportedOSPlatformData ("ios"));
builder.Add (new UnsupportedOSPlatformData ("tvos"));
builder.Add (new SupportedOSPlatformData ("macos"));
builder.Add (new UnsupportedOSPlatformData("maccatalyst"));
builder.Add (new UnsupportedOSPlatformData ("maccatalyst"));
yield return [(Source: allPlatformsRemovedButOne, Path: path), builder.ToImmutable ()];
}

Expand All @@ -126,13 +126,13 @@ void TryCreateTests (ApplePlatform platform, (string Source, string Path) source
{
var compilation = CreateCompilation (platform, sources: source);
var x = compilation.GetDiagnostics ();
var syntaxTree = compilation.SyntaxTrees.FirstOrDefault(t => t.FilePath == source.Path);
var syntaxTree = compilation.SyntaxTrees.FirstOrDefault (t => t.FilePath == source.Path);
Assert.NotNull (syntaxTree);
var declaration = syntaxTree.GetRoot ()
.DescendantNodes ().OfType<BaseTypeDeclarationSyntax> ()
.FirstOrDefault ();
Assert.NotNull (declaration);

var semanticModel = compilation.GetSemanticModel (syntaxTree);
Assert.NotNull (semanticModel);

Expand Down

0 comments on commit 9c2815b

Please sign in to comment.