Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d6405ed
powershell changes for what if
anamikapan11 Mar 19, 2026
98db58b
added generated files and changes for what if
anamikapan11 Mar 26, 2026
e863248
added suggested fixes
anamikapan11 Mar 26, 2026
843e675
Add WhatIf support to Deployment Stack cmdlets with formatted output
anamikapan11 Mar 27, 2026
c5ead2a
Add standalone WhatIf CRUD cmdlets for DeploymentStacks
anamikapan11 Apr 20, 2026
bb331b3
Expanded WhatIf scenario tests - full parameter set coverage and prov…
anamikapan11 Apr 20, 2026
8ab0c45
Remove DEPLOYMENT_STACKS_WHATIF_MODELS_GUIDE.md
anamikapan11 Apr 20, 2026
3a2cdd5
Revert DependencyInjection.Abstractions version to 8.0.2
anamikapan11 Apr 20, 2026
d26666f
Address PR review comments on WhatIf cmdlets
anamikapan11 Apr 21, 2026
cce61e8
Add -WithPropertyChanges flag to Get-Az*WhatIf and default POST on Ne…
anamikapan11 Apr 21, 2026
41c1e2f
Bump DependencyInjection.Abstractions back to 10.0.2
anamikapan11 Apr 21, 2026
0f95424
Remove explicit DependencyInjection.Abstractions version pin
anamikapan11 Apr 21, 2026
66d9c80
Address PR feedback for Deployment Stack WhatIf cmdlets
anamikapan11 Apr 22, 2026
c9b0b62
Address more PR feedback: move WhatIf dir up, split SDK client, rever…
anamikapan11 Apr 22, 2026
3e821b8
Address PR feedback: remove extra ErrorResponseException check + reve…
anamikapan11 Apr 22, 2026
24c918c
Address more PR feedback: remove -WhatIf flag from regular stacks, re…
anamikapan11 Apr 22, 2026
917faaa
Address Copilot review suggestions
anamikapan11 Apr 22, 2026
85ba0e1
Rename cmdlets/models for consistency
anamikapan11 Apr 22, 2026
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
2 changes: 2 additions & 0 deletions src/Resources/ResourceManager/Formatters/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class Color : IEquatable<Color>

public static Color Blue { get; } = new Color($"{Esc}[38;5;39m");

public static Color Cyan { get; } = new Color($"{Esc}[38;5;51m");

public static Color Gray { get; } = new Color($"{Esc}[38;5;246m");

public static Color Reset { get; } = new Color($"{Esc}[0m");
Expand Down
78 changes: 76 additions & 2 deletions src/Resources/ResourceManager/Formatters/ColoredStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class ColoredStringBuilder

private readonly Stack<Color> colorStack = new Stack<Color>();

private readonly List<string> indentStack = new List<string>();

public override string ToString()
{
return stringBuilder.ToString();
Expand Down Expand Up @@ -89,6 +91,78 @@ public AnsiColorScope NewColorScope(Color color)
return new AnsiColorScope(this, color);
}

public void Insert(int index, string value)
{
if (index >= 0 && index <= this.stringBuilder.Length)
{
this.stringBuilder.Insert(index, value);
}
}

public void InsertLine(int index, string value, Color color)
{
if (color != Color.Reset)
{
this.Insert(index, Color.Reset.ToString());
}
this.Insert(index, value + Environment.NewLine);
if (color != Color.Reset)
{
this.Insert(index, color.ToString());
}
}

public int GetCurrentIndex()
{
return this.stringBuilder.Length;
}

public void PushIndent(string indent)
{
this.indentStack.Add(indent);
}
Comment on lines +120 to +123
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PushIndent/PopIndent currently only mutate indentStack, but that stack is never consulted by Append/AppendLine. Callers (e.g., the What-If formatter) push indents expecting output to be indented, but this implementation has no effect. Either implement indentation application (typically by prepending the active indent at the start of new lines) or remove the unused indent stack APIs and update callers accordingly.

Copilot uses AI. Check for mistakes.

public void PopIndent()
{
if (this.indentStack.Count > 0)
{
this.indentStack.RemoveAt(this.indentStack.Count - 1);
}
}
Comment thread
anamikapan11 marked this conversation as resolved.

public void EnsureNumNewLines(int numNewLines)
{
if (this.stringBuilder.Length == 0)
{
for (int i = 0; i < numNewLines; i++)
{
this.stringBuilder.AppendLine();
}
return;
}

string currentText = this.stringBuilder.ToString();
int existingNewlines = 0;

for (int i = currentText.Length - 1; i >= 0 && currentText[i] == '\n'; i--)
{
existingNewlines++;
Comment on lines +146 to +149
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnsureNumNewLines counts only consecutive '\n' characters at the end of the buffer. When the buffer contains Windows newlines ("\r\n" from AppendLine/Environment.NewLine), the trailing characters are not consecutive '\n', so this undercounts existing newlines and may append extra blank lines. Consider counting trailing newline sequences in an OS-agnostic way (e.g., trim trailing "\r"/"\n" and compute how many newline sequences are present, or iterate from the end handling "\r\n" as one).

Suggested change
for (int i = currentText.Length - 1; i >= 0 && currentText[i] == '\n'; i--)
{
existingNewlines++;
int index = currentText.Length - 1;
// Count trailing newline sequences in an OS-agnostic way:
// - Treat "\r\n" as a single newline
// - Also handle lone '\n' and lone '\r'
while (index >= 0)
{
if (currentText[index] == '\n')
{
existingNewlines++;
index--;
// Consume preceding '\r' if this is a Windows newline sequence "\r\n"
if (index >= 0 && currentText[index] == '\r')
{
index--;
}
}
else if (currentText[index] == '\r')
{
existingNewlines++;
index--;
}
else
{
break;
}

Copilot uses AI. Check for mistakes.
}

int remainingNewlines = numNewLines - existingNewlines;
for (int i = 0; i < remainingNewlines; i++)
{
this.stringBuilder.AppendLine();
}
Comment thread
anamikapan11 marked this conversation as resolved.
}

public void Clear()
{
this.stringBuilder.Clear();
this.colorStack.Clear();
this.indentStack.Clear();
}

private void PushColor(Color color)
{
this.colorStack.Push(color);
Expand All @@ -101,7 +175,7 @@ private void PopColor()
this.stringBuilder.Append(this.colorStack.Count > 0 ? this.colorStack.Peek() : Color.Reset);
}

public class AnsiColorScope: IDisposable
public class AnsiColorScope : IDisposable
{
private readonly ColoredStringBuilder builder;

Expand All @@ -117,4 +191,4 @@ public void Dispose()
}
}
}
}
}
Loading