Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@
<InternalsVisibleTo Include="MSTest.AotReflection.SourceGeneration.UnitTests" Key="$(VsPublicKey)" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\MSTest.SourceGeneration\Helpers\Constants.cs" Link="Helpers\Constants.cs" />
<Compile Include="..\MSTest.SourceGeneration\Helpers\IndentedStringBuilder.cs" Link="Helpers\IndentedStringBuilder.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.SourceGeneration.Helpers;

/// <summary>
/// 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.
/// </summary>
internal sealed class IndentedStringBuilder
{
Expand All @@ -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++;

Expand Down