Skip to content

Commit c35a6bd

Browse files
author
GitHub Actions Autoformatter
committed
Auto-format source code
1 parent 694a975 commit c35a6bd

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
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.
@@ -270,8 +270,8 @@ static void GenerateDictionaryExtension (TabbedStringBuilder sb,
270270
// loop over the flags and generate a helper static method to retrieve it from a attribute data dict
271271
foreach (var (methodName, attributeName) in flags) {
272272
using (var methodBlock = classBlock.CreateBlock (
273-
$"public static bool {methodName} (this Dictionary<string, List<AttributeData>> self)",
274-
block: true)) {
273+
$"public static bool {methodName} (this Dictionary<string, List<AttributeData>> self)",
274+
block: true)) {
275275
methodBlock.AppendLine ($"return self.ContainsKey ({attributeName.AttributeFullName});");
276276
}
277277

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

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

src/rgen/Microsoft.Macios.Transformer/Attributes/SnippetData.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
namespace Microsoft.Macios.Transformer.Attributes;
88

99
readonly struct SnippetData : IEquatable<SnippetData> {
10-
10+
1111
public string Code { get; }
1212

1313
public bool Optimizable { get; }
14-
14+
1515
public SnippetData (string code)
1616
{
1717
Code = code;
1818
}
19-
19+
2020
public SnippetData (string code, bool optimizable)
2121
{
2222
Code = code;
@@ -61,10 +61,10 @@ public static bool TryParse (AttributeData attributeData,
6161
}
6262
}
6363

64-
data = new (code, optimizable);
64+
data = new (code, optimizable);
6565
return true;
6666
}
67-
67+
6868
public bool Equals (SnippetData other)
6969
{
7070
if (Code != other.Code)

src/rgen/Microsoft.Macios.Transformer/Attributes/StrongDictionaryData.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
namespace Microsoft.Macios.Transformer.Attributes;
88

99
readonly struct StrongDictionaryData : IEquatable<StrongDictionaryData> {
10-
10+
1111
public string TypeWithKeys { get; }
1212
public string? Suffix { get; }
13-
13+
1414
public StrongDictionaryData (string typeWithKeys)
1515
{
1616
TypeWithKeys = typeWithKeys;
1717
}
18-
18+
1919
public StrongDictionaryData (string typeWithKeys, string? suffix)
2020
{
2121
TypeWithKeys = typeWithKeys;
@@ -60,7 +60,7 @@ public static bool TryParse (AttributeData attributeData,
6060
data = new (typeWithKeys, suffix);
6161
return true;
6262
}
63-
63+
6464
public bool Equals (StrongDictionaryData other)
6565
{
6666
if (TypeWithKeys != other.TypeWithKeys)

src/rgen/Microsoft.Macios.Transformer/Attributes/ThreadSafeData.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
namespace Microsoft.Macios.Transformer.Attributes;
88

99
readonly struct ThreadSafeData : IEquatable<ThreadSafeData> {
10-
10+
1111
public bool Safe { get; } = true;
12-
13-
public ThreadSafeData () : this (true) {}
14-
12+
13+
public ThreadSafeData () : this (true) { }
14+
1515
public ThreadSafeData (bool safe)
1616
{
1717
Safe = safe;
@@ -23,7 +23,7 @@ public static bool TryParse (AttributeData attributeData,
2323
data = null;
2424
var count = attributeData.ConstructorArguments.Length;
2525
if (count == 0) {
26-
data = new();
26+
data = new ();
2727
return true;
2828
}
2929
bool safe = true;

tests/rgen/Microsoft.Macios.Transformer.Tests/Attributes/SnippetDataTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Microsoft.Macios.Transformer.Tests.Attributes;
1313

1414
public class SnippetDataTests : BaseTransformerTestClass {
1515
class TestDataTryCreate : IEnumerable<object []> {
16-
16+
1717
public IEnumerator<object []> GetEnumerator ()
1818
{
1919
const string path = "/some/random/path.cs";
@@ -30,8 +30,8 @@ namespace Test;
3030
[Dispose (""dispatcher = null;"", Optimizable = true)]
3131
interface NSButton { }
3232
";
33-
34-
yield return [(Source: disposeAttribute, Path: path), new SnippetData("dispatcher = null;", true)];
33+
34+
yield return [(Source: disposeAttribute, Path: path), new SnippetData ("dispatcher = null;", true)];
3535
}
3636

3737
IEnumerator IEnumerable.GetEnumerator () => GetEnumerator ();

tests/rgen/Microsoft.Macios.Transformer.Tests/Attributes/StrongDictionaryDataTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Microsoft.Macios.Transformer.Tests.Attributes;
1313

1414
public class StrongDictionaryDataTests : BaseTransformerTestClass {
15-
15+
1616
class TestDataTryCreate : IEnumerable<object []> {
1717
public IEnumerator<object []> GetEnumerator ()
1818
{
@@ -33,8 +33,8 @@ interface AVCapturePhotoSettingsThumbnailFormat {
3333
NSNumber Height { get; set; }
3434
}
3535
";
36-
37-
yield return [(Source: strongDictionary, Path: "/some/random/path.cs"), new StrongDictionaryData("AVCapturePhotoSettingsThumbnailFormatKeys")];
36+
37+
yield return [(Source: strongDictionary, Path: "/some/random/path.cs"), new StrongDictionaryData ("AVCapturePhotoSettingsThumbnailFormatKeys")];
3838
}
3939

4040
IEnumerator IEnumerable.GetEnumerator () => GetEnumerator ();

tests/rgen/Microsoft.Macios.Transformer.Tests/Attributes/ThreadSafeDataTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Microsoft.Macios.Transformer.Tests.Attributes;
1313

1414
public class ThreadSafeDataTests : BaseTransformerTestClass {
15-
15+
1616
class TestDataTryCreate : IEnumerable<object []> {
1717
public IEnumerator<object []> GetEnumerator ()
1818
{
@@ -37,8 +37,8 @@ interface UIFeedbackGenerator : UIInteraction {
3737
void Prepare ();
3838
}
3939
";
40-
41-
yield return [(Source: threadSageMethod, Path: path), new ThreadSafeData()];
40+
41+
yield return [(Source: threadSageMethod, Path: path), new ThreadSafeData ()];
4242

4343
const string notThreadSafeMethod = @"
4444
using System;
@@ -59,8 +59,8 @@ interface UIFeedbackGenerator : UIInteraction {
5959
void Prepare ();
6060
}
6161
";
62-
63-
yield return [(Source: notThreadSafeMethod, Path: path), new ThreadSafeData(false)];
62+
63+
yield return [(Source: notThreadSafeMethod, Path: path), new ThreadSafeData (false)];
6464

6565
}
6666

0 commit comments

Comments
 (0)