From d67bab8e4495aee4f7a432f9ca3dfd4a6c44ccae Mon Sep 17 00:00:00 2001 From: GitHub Actions Autoformatter Date: Sun, 26 Jan 2025 22:47:39 +0000 Subject: [PATCH] Auto-format source code --- .../XamarinBindingAPIGenerator.cs | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/rgen/Microsoft.Macios.Transformer.Generator/Microsoft.Macios.Transformer.Generator/XamarinBindingAPIGenerator.cs b/src/rgen/Microsoft.Macios.Transformer.Generator/Microsoft.Macios.Transformer.Generator/XamarinBindingAPIGenerator.cs index a042699c671..df6dedc052a 100644 --- a/src/rgen/Microsoft.Macios.Transformer.Generator/Microsoft.Macios.Transformer.Generator/XamarinBindingAPIGenerator.cs +++ b/src/rgen/Microsoft.Macios.Transformer.Generator/Microsoft.Macios.Transformer.Generator/XamarinBindingAPIGenerator.cs @@ -73,13 +73,13 @@ static string [] GetFlagsForTarget (Dictionary kv.Key) .ToArray (); - static (string AttributeFullName, string AttributeName, BindingAttributeData Data)[] GetAttributesForTarget ( + static (string AttributeFullName, string AttributeName, BindingAttributeData Data) [] GetAttributesForTarget ( Dictionary dataAttribute, AttributeTargets targets) => dataAttribute.Where (kv => kv.Value.Data.Target.HasFlag (targets)) .Select (kv => kv.Value) .ToArray (); - + static void WriteFlagProperty (TabbedStringBuilder sb, string flagName) { @@ -95,14 +95,14 @@ static void WriteAttributeProperty (TabbedStringBuilder sb, (string AttributeFullName, string AttributeName, BindingAttributeData Data) attrData) { // add a property that will state if we have the attr, this will help with nullability - sb.AppendLine($"readonly bool _has{attrData.AttributeName} = false;"); + sb.AppendLine ($"readonly bool _has{attrData.AttributeName} = false;"); sb.AppendLine ($"[MemberNotNullWhen (true, nameof ({attrData.AttributeName}))]"); using (var flagPropertyBlock = sb.CreateBlock ($"public bool Has{attrData.AttributeName}", block: true)) { flagPropertyBlock.AppendLine ($"get => _has{attrData.AttributeName};"); flagPropertyBlock.AppendLine ($"private init => _has{attrData.AttributeName} = value;"); } - sb.AppendLine (); - sb.AppendLine($"readonly {attrData.Data.DataModelType}? _{attrData.AttributeName} = null;"); + sb.AppendLine (); + sb.AppendLine ($"readonly {attrData.Data.DataModelType}? _{attrData.AttributeName} = null;"); // decorate to help with nullability using (var attributePropertyBlock = sb.CreateBlock ($"public {attrData.Data.DataModelType}? {attrData.AttributeName}", block: true)) { attributePropertyBlock.AppendLine ($"get => _{attrData.AttributeName};"); @@ -110,8 +110,8 @@ static void WriteAttributeProperty (TabbedStringBuilder sb, } } - static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, string [] flags, - (string AttributeFullName, string AttributeName, BindingAttributeData Data)[] attributes) + static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, string [] flags, + (string AttributeFullName, string AttributeName, BindingAttributeData Data) [] attributes) { sb.Clear (); sb.AppendLine ("// "); @@ -141,8 +141,8 @@ static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, s modelBlock.AppendLine (); modelBlock.AppendLine ("readonly Dictionary>? _attributesDictionary = null;"); using (var dictionaryPropertyBlock = - modelBlock.CreateBlock ("public Dictionary>? AttributesDictionary", - block: true)) { + modelBlock.CreateBlock ("public Dictionary>? AttributesDictionary", + block: true)) { dictionaryPropertyBlock.AppendLine ("get => _attributesDictionary;"); using (var initBlock = dictionaryPropertyBlock.CreateBlock ("private init", block: true)) { initBlock.AppendLine ("_attributesDictionary = value;"); @@ -153,7 +153,7 @@ static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, s foreach (var attributeData in attributes) { // check if the attribute is present, if it is, set the value - ifBlock.AppendLine($"Has{attributeData.AttributeName} = _attributesDictionary.Has{attributeData.AttributeName} ();"); + ifBlock.AppendLine ($"Has{attributeData.AttributeName} = _attributesDictionary.Has{attributeData.AttributeName} ();"); using (var attrIfBlock = ifBlock.CreateBlock ($"if (Has{attributeData.AttributeName})", block: true)) { attrIfBlock.AppendLine ($"{attributeData.AttributeName} = _attributesDictionary.Get{attributeData.AttributeName} ();"); } @@ -165,8 +165,8 @@ static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, s } static void GenerateModelExtension (TabbedStringBuilder sb, string dataModel, - Dictionary flags, - Dictionary attributes, + Dictionary flags, + Dictionary attributes, AttributeTargets targets, SourceProductionContext context) { @@ -183,7 +183,7 @@ static AttributeTargets GetTarget (ISymbol symbol) // loop over attrs, if we find the BindingFlagAttribute, return the target foreach (var attr in attrData) { if (attr.AttributeClass?.Name == BindingFlagData.Name - && BindingFlagData.TryParse (attr, out var data)) { + && BindingFlagData.TryParse (attr, out var data)) { return data.Value.Target; } } @@ -197,7 +197,7 @@ static AttributeTargets GetTarget (ISymbol symbol) // loop over attrs, if we find the BindingFlagAttribute, return the target foreach (var attr in attrData) { if (attr.AttributeClass?.Name == BindingAttributeData.Name - && BindingAttributeData.TryParse (attr, out var data)) { + && BindingAttributeData.TryParse (attr, out var data)) { return data; } } @@ -229,7 +229,7 @@ void GenerateCode (SourceProductionContext context, Compilation compilation, } // all flags are collected, generate the code - var sb = new TabbedStringBuilder (new()); + var sb = new TabbedStringBuilder (new ()); GenerateDictionaryExtension (sb, flags, dataAttributes); // Add the source code to the compilation. @@ -269,8 +269,8 @@ static void GenerateDictionaryExtension (TabbedStringBuilder sb, // loop over the flags and generate a helper static method to retrieve it from a attribute data dict foreach (var (methodName, attributeName) in flags) { using (var methodBlock = classBlock.CreateBlock ( - $"public static bool {methodName} (this Dictionary> self)", - block: true)) { + $"public static bool {methodName} (this Dictionary> self)", + block: true)) { methodBlock.AppendLine ($"return self.ContainsKey ({attributeName.AttributeFullName});"); } @@ -281,16 +281,16 @@ static void GenerateDictionaryExtension (TabbedStringBuilder sb, foreach (var (methodName, attributeInfo) in dataAttributes) { // property to check if the attribute is present using (var methodBlock = classBlock.CreateBlock ( - $"public static bool {methodName} (this Dictionary> self)", - block: true)) { + $"public static bool {methodName} (this Dictionary> self)", + block: true)) { methodBlock.AppendLine ($"return self.ContainsKey ({attributeInfo.AttributeFullName});"); } classBlock.AppendLine (); // property to access the attribute using (var methodBlock = classBlock.CreateBlock ( - $"public static {attributeInfo.Data.DataModelType}? Get{attributeInfo.AttributeName} (this Dictionary> self)", - block: true)) { + $"public static {attributeInfo.Data.DataModelType}? Get{attributeInfo.AttributeName} (this Dictionary> self)", + block: true)) { methodBlock.AppendRaw ( $@"if (self.{methodName} ()) {{ var data = self.GetAttribute<{attributeInfo.Data.DataModelType}> ({attributeInfo.AttributeFullName}, {attributeInfo.Data.DataModelType}.TryParse);