Skip to content

C#: Escape IDs in TRAP label definitions#5848

Merged
hvitved merged 3 commits intogithub:mainfrom
hvitved:csharp/trap-key-escape
May 10, 2021
Merged

C#: Escape IDs in TRAP label definitions#5848
hvitved merged 3 commits intogithub:mainfrom
hvitved:csharp/trap-key-escape

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented May 6, 2021

@github-actions github-actions bot added the C# label May 6, 2021
@hvitved hvitved force-pushed the csharp/trap-key-escape branch 2 times, most recently from 3eee4ba to c3d6eb4 Compare May 6, 2021 15:47
@hvitved hvitved force-pushed the csharp/trap-key-escape branch from c3d6eb4 to fab8400 Compare May 6, 2021 17:12
@hvitved hvitved marked this pull request as ready for review May 7, 2021 08:57
@hvitved hvitved requested a review from a team as a code owner May 7, 2021 08:57
@hvitved hvitved added the no-change-note-required This PR does not need a change note label May 7, 2021

public abstract string NameLabel { get; }

protected internal void WriteMethodId(TextWriter trapFile, Type parent, string methodName)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is strange. Why was this protected internal?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea :-)

Comment on lines +89 to +93
public override void Close()
=> throw new NotImplementedException();

public override ValueTask DisposeAsync()
=> throw new NotImplementedException();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why aren't these calling the wrapped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't bother to implement those because we are not using them.

Comment on lines +95 to +96
public override bool Equals(object? obj)
=> wrapped.Equals(obj);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this okay? Shouldn't disposeUnderlying be included here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

private readonly TextWriter wrapped;
private readonly bool disposeUnderlying;

public EscapingTextWriter(TextWriter wrapped, bool disposeUnderlying = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this wrapped TextWriter? Wouldn't the following be enough?

public class EscapingStringWriter : StringWriter
{
  public override void Write(char value) => WriteEscaped(value);
  private void WriteEscaped(char c)
  { ... }
}

Maybe we would also need to override void Write(char[] buffer, int index, int count), but most probably all other Write* just calls Write(char).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When writing actual TRAP we are using an underlying StreamWriter, so it is not always a StringWriter.

@hvitved hvitved merged commit 498f9b2 into github:main May 10, 2021
@hvitved hvitved deleted the csharp/trap-key-escape branch May 10, 2021 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants