Escape characters in diffable cs field default values#386
Merged
SamboyCoding merged 3 commits intoSamboyCoding:developmentfrom Dec 8, 2024
Merged
Escape characters in diffable cs field default values#386SamboyCoding merged 3 commits intoSamboyCoding:developmentfrom
SamboyCoding merged 3 commits intoSamboyCoding:developmentfrom
Conversation
Contributor
| This feels like a hack. Ideally, your pr would fix the underlying issue. How about you post the stack trace you encountered and information about how it can be reproduced. |
ds5678 approved these changes Dec 7, 2024
SamboyCoding approved these changes Dec 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
System.Globalization.CharUnicodeInfo is supposed to look like this:
public static class CharUnicodeInfo
{
internal const char HIGH_SURROGATE_START = '\ud800';
internal const char HIGH_SURROGATE_END = '\udbff';
internal const char LOW_SURROGATE_START = '\udc00';
internal const char LOW_SURROGATE_END = '\udfff';
and in DiffableCsOutputFormat.cs line 184 those default values are characters, not strings
if (defaultValue is string stringDefaultValue)
sb.Append('"').Append(stringDefaultValue).Append('"');
else
sb.Append(defaultValue); // it tries to do this, but it cant be encoded
public static class CharUnicodeInfo
{
internal const char HIGH_SURROGATE_START = �;
internal const char HIGH_SURROGATE_END = �;
internal const char LOW_SURROGATE_START = �;
internal const char LOW_SURROGATE_END = �;
Unhandled exception. System.Text.EncoderFallbackException: Unable to translate Unicode character \uD800 at index 119 to specified code page.
at System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
at System.Text.Encoding.GetBytesWithFallback(ReadOnlySpan
1 chars, Int32 originalCharsLength, Span1 bytes, Int32 originalBytesLength, EncoderNLS encoder, Boolean throwForDestinationOverflow)at System.Text.Encoding.GetBytesWithFallback(Char* pOriginalChars, Int32 originalCharCount, Byte* pOriginalBytes, Int32 originalByteCount, Int32 charsConsumedSoFar, Int32 bytesWrittenSoFar, EncoderNLS encoder)
at System.IO.File.WriteToFile(String path, FileMode mode, ReadOnlySpan`1 contents, Encoding encoding)
at System.IO.File.WriteAllText(String path, String contents)
at Cpp2IL.Core.OutputFormats.DiffableCsOutputFormat.DoOutput(ApplicationAnalysisContext context, String outputRoot) in Cpp2IL.Core\OutputFormats\DiffableCsOutputFormat.cs:line 46
at Cpp2IL.Program.MainWithArgs(Cpp2IlRuntimeArgs runtimeArgs) in Cpp2IL\Program.cs:line 613
at Cpp2IL.Program.Main(String[] args) in Cpp2IL\Program.cs:line 531