Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized escape sequence error in pattern-based record struct definition #12

Open
koddek opened this issue Aug 30, 2024 · 1 comment

Comments

@koddek
Copy link

koddek commented Aug 30, 2024

When I try to build this code:

public const string Pattern2 = "^[a-zA-Z0-9._%+-]{1,64}@[a-zA-Z0-9.-]{1,255}\\.[a-zA-Z]{2,}$";
public const string Pattern3 = """^[a-zA-Z0-9._%+-]{1,64}@[a-zA-Z0-9.-]{1,255}\.[a-zA-Z]{2,}$""";

[String(minLength: 6, maxLength: 99,Pattern = Pattern1)]
public readonly partial record struct Email;

I get this error for both ways of arranging the pattern:

0>PrimitiveRepository.g.cs(35,200): Error CS1009 : Unrecognized escape sequence

@koddek
Copy link
Author

koddek commented Aug 30, 2024

After some more testing, I realise that the code generation fails when there are escaped characters in the pattern. Anything with the '\' character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant