diff --git a/src/Analyzers/MSTest.AotReflection.SourceGeneration/Generators/MetadataRegistryEmitter.cs b/src/Analyzers/MSTest.AotReflection.SourceGeneration/Generators/MetadataRegistryEmitter.cs
index e7ae151cb8..d62a57defd 100644
--- a/src/Analyzers/MSTest.AotReflection.SourceGeneration/Generators/MetadataRegistryEmitter.cs
+++ b/src/Analyzers/MSTest.AotReflection.SourceGeneration/Generators/MetadataRegistryEmitter.cs
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-using MSTest.AotReflection.SourceGeneration.Helpers;
+using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.SourceGeneration.Helpers;
+
using MSTest.AotReflection.SourceGeneration.Model;
namespace MSTest.AotReflection.SourceGeneration.Generators;
diff --git a/src/Analyzers/MSTest.AotReflection.SourceGeneration/Helpers/IndentedStringBuilder.cs b/src/Analyzers/MSTest.AotReflection.SourceGeneration/Helpers/IndentedStringBuilder.cs
deleted file mode 100644
index 6899b7cce4..0000000000
--- a/src/Analyzers/MSTest.AotReflection.SourceGeneration/Helpers/IndentedStringBuilder.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-
-namespace MSTest.AotReflection.SourceGeneration.Helpers;
-
-///
-/// A small wrapper that tracks an indentation level so the
-/// generated code stays readable. Kept private to this PoC to avoid pulling in the
-/// equivalent helper that lives in MSTest.SourceGeneration.
-///
-internal sealed class IndentedStringBuilder
-{
- private const string IndentUnit = " ";
- private readonly StringBuilder _builder = new();
- private int _indent;
- private bool _needsIndent = true;
-
- public IndentedStringBuilder AppendLine(string value)
- {
- EnsureIndent();
- _builder.AppendLine(value);
- _needsIndent = true;
- return this;
- }
-
- public IndentedStringBuilder AppendLine()
- {
- _builder.AppendLine();
- _needsIndent = true;
- return this;
- }
-
- public IndentedStringBuilder Append(string value)
- {
- EnsureIndent();
- _builder.Append(value);
- return this;
- }
-
- public IDisposable Block(string? header = null)
- {
- if (header is not null)
- {
- AppendLine(header);
- }
-
- AppendLine("{");
- _indent++;
- return new BlockScope(this);
- }
-
- public override string ToString() => _builder.ToString();
-
- private void EnsureIndent()
- {
- if (!_needsIndent)
- {
- return;
- }
-
- for (int i = 0; i < _indent; i++)
- {
- _builder.Append(IndentUnit);
- }
-
- _needsIndent = false;
- }
-
- private sealed class BlockScope : IDisposable
- {
- private readonly IndentedStringBuilder _owner;
- private bool _closed;
-
- public BlockScope(IndentedStringBuilder owner) => _owner = owner;
-
- public void Dispose()
- {
- if (_closed)
- {
- return;
- }
-
- _closed = true;
- _owner._indent--;
- _owner.AppendLine("}");
- }
- }
-}
diff --git a/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj b/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj
index dc9bbade05..b88c34a107 100644
--- a/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj
+++ b/src/Analyzers/MSTest.AotReflection.SourceGeneration/MSTest.AotReflection.SourceGeneration.csproj
@@ -33,4 +33,9 @@
+
+
+
+
+
diff --git a/src/Analyzers/MSTest.SourceGeneration/Helpers/IndentedStringBuilder.cs b/src/Analyzers/MSTest.SourceGeneration/Helpers/IndentedStringBuilder.cs
index 6b7937ade5..cfe869617f 100644
--- a/src/Analyzers/MSTest.SourceGeneration/Helpers/IndentedStringBuilder.cs
+++ b/src/Analyzers/MSTest.SourceGeneration/Helpers/IndentedStringBuilder.cs
@@ -4,9 +4,8 @@
namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.SourceGeneration.Helpers;
///
-/// Small helper that produces indented source text. Mirrors the helper used by the existing
-/// MSTest.SourceGeneration project so that the generated output is consistent with the rest of
-/// the MSTest source generators.
+/// Canonical source-generator indentation helper. This file is linked by
+/// MSTest.AotReflection.SourceGeneration so both generators use deterministic newlines.
///
internal sealed class IndentedStringBuilder
{
@@ -17,30 +16,40 @@ internal sealed class IndentedStringBuilder
public int IndentationLevel { get; internal set; }
- public void Append(string value)
+ public IndentedStringBuilder Append(string value)
{
MaybeAppendIndent();
_builder.Append(value);
_needsIndent = false;
+
+ return this;
}
- public void AppendLine()
+ public IndentedStringBuilder AppendLine()
{
_builder.Append(Constants.NewLine);
_needsIndent = true;
+
+ return this;
}
- public void AppendLine(string value)
+ public IndentedStringBuilder AppendLine(string value)
{
MaybeAppendIndent();
_builder.Append(value);
_builder.Append(Constants.NewLine);
_needsIndent = true;
+
+ return this;
}
- public IDisposable AppendBlock(string header)
+ public IDisposable Block(string? header = null)
{
- AppendLine(header);
+ if (header is not null)
+ {
+ AppendLine(header);
+ }
+
AppendLine("{");
IndentationLevel++;