Skip to content

Commit

Permalink
[Rgen] Allow the transformer to use the tabbed string builder. (#22020)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque authored Jan 21, 2025
1 parent 3a0fb1a commit 1480b5d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using Microsoft.Macios.Generator.Attributes;
using ObjCRuntime;

namespace Microsoft.Macios.Generator;

partial class TabbedStringBuilder {

public TabbedStringBuilder AppendExportData<T> (in ExportData<T> exportData) where T : Enum
{
// Try to write the smaller amount of data. We are using the old ExportAttribute until we make the final move
if (exportData.ArgumentSemantic != ArgumentSemantic.None) {
AppendLine ($"[Export (\"{exportData.Selector}\", ArgumentSemantic.{exportData.ArgumentSemantic})]");
} else {
AppendLine ($"[Export (\"{exportData.Selector}\")]");
}
return this;
}
}
20 changes: 1 addition & 19 deletions src/rgen/Microsoft.Macios.Generator/TabbedStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,9 @@
// Licensed under the MIT License.
using System;
using System.ComponentModel;
using System.Linq;
using System.Net.Http;
using System.Net.Mail;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using Microsoft.Macios.Generator.Attributes;
using Microsoft.Macios.Generator.Availability;
using Microsoft.Macios.Generator.DataModel;
using ObjCRuntime;
using Xamarin.Utils;

namespace Microsoft.Macios.Generator;
Expand All @@ -29,7 +22,7 @@ namespace Microsoft.Macios.Generator;
/// }
/// </example>
/// </summary>
class TabbedStringBuilder : IDisposable {
partial class TabbedStringBuilder : IDisposable {
readonly StringBuilder sb;
readonly uint tabCount;
readonly bool isBlock;
Expand Down Expand Up @@ -229,17 +222,6 @@ public TabbedStringBuilder AppendMemberAvailability (in SymbolAvailability allPl
return this;
}

public TabbedStringBuilder AppendExportData<T> (in ExportData<T> exportData) where T : Enum
{
// Try to write the smaller amount of data. We are using the old ExportAttribute until we make the final move
if (exportData.ArgumentSemantic != ArgumentSemantic.None) {
AppendLine ($"[Export (\"{exportData.Selector}\", ArgumentSemantic.{exportData.ArgumentSemantic})]");
} else {
AppendLine ($"[Export (\"{exportData.Selector}\")]");
}
return this;
}

public TabbedStringBuilder AppendNotificationAdvice (in string className, in string notification)
{
string attr =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<Compile Include="../Microsoft.Macios.Generator/CollectionComparer.cs" >
<Link>CollectionComparer.cs</Link>
</Compile>
<Compile Include="../Microsoft.Macios.Generator/TabbedStringBuilder.cs" >
<Link>TabbedStringBuilder.cs</Link>
</Compile>
<Compile Include="../Microsoft.Macios.Generator/Attributes/ObsoletedOSPlatformData.cs" >
<Link>Attributes/ObsoletedOSPlatformData.cs</Link>
</Compile>
Expand Down

0 comments on commit 1480b5d

Please sign in to comment.