Skip to content

Escape assembly name when starting with number - #2013

Merged
Manodasan Wignarajah (manodasanW) merged 3 commits into
staging/2.3from
manodasanw/fixleadingnumber
Jul 11, 2025
Merged

Manodasan Wignarajah (manodasanW) merged 3 commits into
staging/2.3from
manodasanw/fixleadingnumber

Conversation

@manodasanW

Copy link
Copy Markdown
Member

Fixes #1880

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that assembly names beginning with a digit are prefixed with an underscore before sanitizing, preventing invalid identifiers.

  • Prefixes an underscore when the input starts with a numeric character
  • Continues to replace all non-alphanumeric/underscore characters with underscores
Comments suppressed due to low confidence (1)

src/Authoring/WinRT.SourceGenerator/Helper.cs:1241

  • Add a unit test for inputs starting with a digit (e.g., "1MyLib") to verify the underscore prefixing behavior is applied correctly.
            var prefixedTypeName = Regex.Match(typeName, @"(^\d)").Success ? "_" + typeName : typeName;

Comment thread src/Authoring/WinRT.SourceGenerator/Helper.cs Outdated
Comment thread src/Authoring/WinRT.SourceGenerator/Helper.cs
@manodasanW
Manodasan Wignarajah (manodasanW) merged commit d5abe78 into staging/2.3 Jul 11, 2025
@manodasanW
Manodasan Wignarajah (manodasanW) deleted the manodasanw/fixleadingnumber branch July 11, 2025 21:03
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

Successfully merging this pull request may close these issues.

3 participants