Skip to content

Commit b8e9cb1

Browse files
author
GitHub Actions Autoformatter
committed
Auto-format source code
1 parent 7cfbb0e commit b8e9cb1

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/rgen/Microsoft.Macios.Transformer.Generator/Microsoft.Macios.Transformer.Generator/XamarinBindingAPIGenerator.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void Initialize (IncrementalGeneratorInitializationContext context)
6868
}
6969

7070
static string [] GetFlagsForTarget (Dictionary<string, (string AttributeFullName, AttributeTargets Targets)> flags,
71-
AttributeTargets[] targets)
71+
AttributeTargets [] targets)
7272
=> flags.Where (kv => targets.Any (t => kv.Value.Targets.HasFlag (t)))
7373
.Select (kv => kv.Key)
7474
.ToArray ();
@@ -80,7 +80,7 @@ static string [] GetFlagsForTarget (Dictionary<string, (string AttributeFullName
8080
=> dataAttribute.Where (kv => targets.Any (t => kv.Value.Data.Target.HasFlag (t)))
8181
.Select (kv => kv.Value)
8282
.ToArray ();
83-
83+
8484

8585
static void WriteFlagProperty (TabbedStringBuilder sb, string flagName)
8686
{
@@ -96,23 +96,23 @@ static void WriteAttributeProperty (TabbedStringBuilder sb,
9696
(string AttributeFullName, string AttributeName, BindingAttributeData Data) attrData)
9797
{
9898
// add a property that will state if we have the attr, this will help with nullability
99-
sb.AppendLine($"readonly bool _has{attrData.AttributeName} = false;");
99+
sb.AppendLine ($"readonly bool _has{attrData.AttributeName} = false;");
100100
sb.AppendLine ($"[MemberNotNullWhen (true, nameof ({attrData.AttributeName}))]");
101101
using (var flagPropertyBlock = sb.CreateBlock ($"public bool Has{attrData.AttributeName}", block: true)) {
102102
flagPropertyBlock.AppendLine ($"get => _has{attrData.AttributeName};");
103103
flagPropertyBlock.AppendLine ($"private init => _has{attrData.AttributeName} = value;");
104104
}
105-
sb.AppendLine ();
106-
sb.AppendLine($"readonly {attrData.Data.DataModelType}? _{attrData.AttributeName} = null;");
105+
sb.AppendLine ();
106+
sb.AppendLine ($"readonly {attrData.Data.DataModelType}? _{attrData.AttributeName} = null;");
107107
// decorate to help with nullability
108108
using (var attributePropertyBlock = sb.CreateBlock ($"public {attrData.Data.DataModelType}? {attrData.AttributeName}", block: true)) {
109109
attributePropertyBlock.AppendLine ($"get => _{attrData.AttributeName};");
110110
attributePropertyBlock.AppendLine ($"private init => _{attrData.AttributeName} = value;");
111111
}
112112
}
113113

114-
static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, string [] flags,
115-
(string AttributeFullName, string AttributeName, BindingAttributeData Data)[] attributes)
114+
static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, string [] flags,
115+
(string AttributeFullName, string AttributeName, BindingAttributeData Data) [] attributes)
116116
{
117117
sb.Clear ();
118118
sb.AppendLine ("// <auto-generated/>");
@@ -142,8 +142,8 @@ static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, s
142142
modelBlock.AppendLine ();
143143
modelBlock.AppendLine ("readonly Dictionary<string, List<AttributeData>>? _attributesDictionary = null;");
144144
using (var dictionaryPropertyBlock =
145-
modelBlock.CreateBlock ("public Dictionary<string, List<AttributeData>>? AttributesDictionary",
146-
block: true)) {
145+
modelBlock.CreateBlock ("public Dictionary<string, List<AttributeData>>? AttributesDictionary",
146+
block: true)) {
147147
dictionaryPropertyBlock.AppendLine ("get => _attributesDictionary;");
148148
using (var initBlock = dictionaryPropertyBlock.CreateBlock ("private init", block: true)) {
149149
initBlock.AppendLine ("_attributesDictionary = value;");
@@ -154,7 +154,7 @@ static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, s
154154

155155
foreach (var attributeData in attributes) {
156156
// check if the attribute is present, if it is, set the value
157-
ifBlock.AppendLine($"Has{attributeData.AttributeName} = _attributesDictionary.Has{attributeData.AttributeName} ();");
157+
ifBlock.AppendLine ($"Has{attributeData.AttributeName} = _attributesDictionary.Has{attributeData.AttributeName} ();");
158158
using (var attrIfBlock = ifBlock.CreateBlock ($"if (Has{attributeData.AttributeName})", block: true)) {
159159
attrIfBlock.AppendLine ($"{attributeData.AttributeName} = _attributesDictionary.Get{attributeData.AttributeName} ();");
160160
}
@@ -166,9 +166,9 @@ static void WriteDataModelExtension (TabbedStringBuilder sb, string dataModel, s
166166
}
167167

168168
static void GenerateModelExtension (TabbedStringBuilder sb, string dataModel,
169-
Dictionary<string, (string AttributeFullName, AttributeTargets Targets)> flags,
170-
Dictionary<string, (string AttributeFullName, string AttributeName, BindingAttributeData Data)> attributes,
171-
AttributeTargets[] targets,
169+
Dictionary<string, (string AttributeFullName, AttributeTargets Targets)> flags,
170+
Dictionary<string, (string AttributeFullName, string AttributeName, BindingAttributeData Data)> attributes,
171+
AttributeTargets [] targets,
172172
SourceProductionContext context)
173173
{
174174
var methodFlags = GetFlagsForTarget (flags, targets);
@@ -184,7 +184,7 @@ static AttributeTargets GetTarget (ISymbol symbol)
184184
// loop over attrs, if we find the BindingFlagAttribute, return the target
185185
foreach (var attr in attrData) {
186186
if (attr.AttributeClass?.Name == BindingFlagData.Name
187-
&& BindingFlagData.TryParse (attr, out var data)) {
187+
&& BindingFlagData.TryParse (attr, out var data)) {
188188
return data.Value.Target;
189189
}
190190
}
@@ -198,7 +198,7 @@ static AttributeTargets GetTarget (ISymbol symbol)
198198
// loop over attrs, if we find the BindingFlagAttribute, return the target
199199
foreach (var attr in attrData) {
200200
if (attr.AttributeClass?.Name == BindingAttributeData.Name
201-
&& BindingAttributeData.TryParse (attr, out var data)) {
201+
&& BindingAttributeData.TryParse (attr, out var data)) {
202202
return data;
203203
}
204204
}
@@ -230,7 +230,7 @@ void GenerateCode (SourceProductionContext context, Compilation compilation,
230230
}
231231

232232
// all flags are collected, generate the code
233-
var sb = new TabbedStringBuilder (new());
233+
var sb = new TabbedStringBuilder (new ());
234234
GenerateDictionaryExtension (sb, flags, dataAttributes);
235235

236236
// Add the source code to the compilation.
@@ -271,8 +271,8 @@ static void GenerateDictionaryExtension (TabbedStringBuilder sb,
271271
// loop over the flags and generate a helper static method to retrieve it from a attribute data dict
272272
foreach (var (methodName, attributeName) in flags) {
273273
using (var methodBlock = classBlock.CreateBlock (
274-
$"public static bool {methodName} (this Dictionary<string, List<AttributeData>> self)",
275-
block: true)) {
274+
$"public static bool {methodName} (this Dictionary<string, List<AttributeData>> self)",
275+
block: true)) {
276276
methodBlock.AppendLine ($"return self.ContainsKey ({attributeName.AttributeFullName});");
277277
}
278278

@@ -283,16 +283,16 @@ static void GenerateDictionaryExtension (TabbedStringBuilder sb,
283283
foreach (var (methodName, attributeInfo) in dataAttributes) {
284284
// property to check if the attribute is present
285285
using (var methodBlock = classBlock.CreateBlock (
286-
$"public static bool {methodName} (this Dictionary<string, List<AttributeData>> self)",
287-
block: true)) {
286+
$"public static bool {methodName} (this Dictionary<string, List<AttributeData>> self)",
287+
block: true)) {
288288
methodBlock.AppendLine ($"return self.ContainsKey ({attributeInfo.AttributeFullName});");
289289
}
290290

291291
classBlock.AppendLine ();
292292
// property to access the attribute
293293
using (var methodBlock = classBlock.CreateBlock (
294-
$"public static {attributeInfo.Data.DataModelType}? Get{attributeInfo.AttributeName} (this Dictionary<string, List<AttributeData>> self)",
295-
block: true)) {
294+
$"public static {attributeInfo.Data.DataModelType}? Get{attributeInfo.AttributeName} (this Dictionary<string, List<AttributeData>> self)",
295+
block: true)) {
296296
methodBlock.AppendRaw (
297297
$@"if (self.{methodName} ()) {{
298298
var data = self.GetAttribute<{attributeInfo.Data.DataModelType}> ({attributeInfo.AttributeFullName}, {attributeInfo.Data.DataModelType}.TryParse);

src/rgen/Microsoft.Macios.Transformer/DataModel/Accessor.Transformer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ namespace Microsoft.Macios.Generator.DataModel;
88
readonly partial struct Accessor {
99

1010
public ExportData? ExportPropertyData { get; init; }
11-
12-
public Accessor () {}
11+
12+
public Accessor () { }
1313
}

0 commit comments

Comments
 (0)