Skip to content

Commit 24dd92f

Browse files
Remove file-path writing overloads from generator library
All IO is now exclusively in the MSBuild task. The generator library only exposes stream/content-based APIs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7f8afd7 commit 24dd92f

File tree

5 files changed

+0
-103
lines changed

5 files changed

+0
-103
lines changed

src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/JcwJavaSourceGenerator.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,40 +41,6 @@ namespace Microsoft.Android.Sdk.TrimmableTypeMap;
4141
/// </remarks>
4242
public sealed class JcwJavaSourceGenerator
4343
{
44-
/// <summary>
45-
/// Generates .java source files for all ACW types and writes them to the output directory.
46-
/// Returns the list of generated file paths.
47-
/// </summary>
48-
public IReadOnlyList<string> Generate (IReadOnlyList<JavaPeerInfo> types, string outputDirectory)
49-
{
50-
if (types is null) {
51-
throw new ArgumentNullException (nameof (types));
52-
}
53-
if (outputDirectory is null) {
54-
throw new ArgumentNullException (nameof (outputDirectory));
55-
}
56-
57-
var generatedFiles = new List<string> ();
58-
59-
foreach (var type in types) {
60-
if (type.DoNotGenerateAcw || type.IsInterface) {
61-
continue;
62-
}
63-
64-
string filePath = GetOutputFilePath (type, outputDirectory);
65-
string? dir = Path.GetDirectoryName (filePath);
66-
if (dir != null) {
67-
Directory.CreateDirectory (dir);
68-
}
69-
70-
using var writer = new StreamWriter (filePath);
71-
Generate (type, writer);
72-
generatedFiles.Add (filePath);
73-
}
74-
75-
return generatedFiles;
76-
}
77-
7844
public IReadOnlyList<GeneratedJavaSource> GenerateContent (IReadOnlyList<JavaPeerInfo> types)
7945
{
8046
if (types is null) throw new ArgumentNullException (nameof (types));
@@ -110,10 +76,6 @@ static string GetRelativePath (JavaPeerInfo type)
11076
return type.JavaName + ".java";
11177
}
11278

113-
static string GetOutputFilePath (JavaPeerInfo type, string outputDirectory)
114-
{
115-
return Path.Combine (outputDirectory, GetRelativePath (type));
116-
}
11779

11880
/// <summary>
11981
/// Validates that the JNI name is well-formed: non-empty, each segment separated by '/'

src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/PEAssemblyBuilder.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,6 @@ public void EmitPreamble (string assemblyName, string moduleName, ReadOnlySpan<b
9494
MetadataTokens.MethodDefinitionHandle (1));
9595
}
9696

97-
/// <summary>
98-
/// Serialises the metadata + IL into a PE DLL at <paramref name="outputPath"/>.
99-
/// </summary>
100-
public void WritePE (string outputPath)
101-
{
102-
var dir = Path.GetDirectoryName (outputPath);
103-
if (!string.IsNullOrEmpty (dir)) {
104-
Directory.CreateDirectory (dir);
105-
}
106-
107-
using var fs = File.Create (outputPath);
108-
WritePE (fs);
109-
}
110-
11197
/// <summary>
11298
/// Serialises the metadata + IL into a PE DLL and writes it to the given <paramref name="stream"/>.
11399
/// </summary>

src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/RootTypeMapAssemblyGenerator.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,6 @@ public RootTypeMapAssemblyGenerator (Version systemRuntimeVersion)
3131
_systemRuntimeVersion = systemRuntimeVersion ?? throw new ArgumentNullException (nameof (systemRuntimeVersion));
3232
}
3333

34-
/// <summary>
35-
/// Generates the root typemap assembly and writes it to a file.
36-
/// </summary>
37-
/// <param name="perAssemblyTypeMapNames">Names of per-assembly typemap assemblies to reference.</param>
38-
/// <param name="outputPath">Path to write the output .dll.</param>
39-
/// <param name="assemblyName">Optional assembly name (defaults to _Microsoft.Android.TypeMaps).</param>
40-
public void Generate (IReadOnlyList<string> perAssemblyTypeMapNames, string outputPath, string? assemblyName = null)
41-
{
42-
if (outputPath is null) {
43-
throw new ArgumentNullException (nameof (outputPath));
44-
}
45-
46-
var dir = Path.GetDirectoryName (outputPath);
47-
if (!string.IsNullOrEmpty (dir)) {
48-
Directory.CreateDirectory (dir);
49-
}
50-
51-
var moduleName = Path.GetFileName (outputPath);
52-
using var fs = File.Create (outputPath);
53-
Generate (perAssemblyTypeMapNames, fs, assemblyName, moduleName);
54-
}
55-
5634
/// <summary>
5735
/// Generates the root typemap assembly and writes it to the given stream.
5836
/// </summary>

src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/TypeMapAssemblyEmitter.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,6 @@ public TypeMapAssemblyEmitter (Version systemRuntimeVersion)
118118
_pe = new PEAssemblyBuilder (_systemRuntimeVersion);
119119
}
120120

121-
/// <summary>
122-
/// Emits a PE assembly from the given model and writes it to <paramref name="outputPath"/>.
123-
/// </summary>
124-
public void Emit (TypeMapAssemblyData model, string outputPath)
125-
{
126-
if (model is null) {
127-
throw new ArgumentNullException (nameof (model));
128-
}
129-
if (outputPath is null) {
130-
throw new ArgumentNullException (nameof (outputPath));
131-
}
132-
133-
EmitCore (model);
134-
_pe.WritePE (outputPath);
135-
}
136-
137121
/// <summary>
138122
/// Emits a PE assembly from the given model and writes it to <paramref name="stream"/>.
139123
/// </summary>

src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/TypeMapAssemblyGenerator.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@ public TypeMapAssemblyGenerator (Version systemRuntimeVersion)
1818
_systemRuntimeVersion = systemRuntimeVersion ?? throw new ArgumentNullException (nameof (systemRuntimeVersion));
1919
}
2020

21-
/// <summary>
22-
/// Generates a TypeMap PE assembly from the given Java peer info records.
23-
/// </summary>
24-
/// <param name="peers">Scanned Java peer types.</param>
25-
/// <param name="outputPath">Path where the output .dll will be written.</param>
26-
/// <param name="assemblyName">Optional explicit assembly name. Derived from outputPath if null.</param>
27-
public void Generate (IReadOnlyList<JavaPeerInfo> peers, string outputPath, string? assemblyName = null)
28-
{
29-
var model = ModelBuilder.Build (peers, outputPath, assemblyName);
30-
var emitter = new TypeMapAssemblyEmitter (_systemRuntimeVersion);
31-
emitter.Emit (model, outputPath);
32-
}
33-
3421
/// <summary>
3522
/// Generates a TypeMap PE assembly from the given Java peer info records and writes it to <paramref name="stream"/>.
3623
/// </summary>

0 commit comments

Comments
 (0)