File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -911,5 +911,19 @@ public void VersionedEvent_EnumerateTemplatesHasEntryPerVersion()
911911 }
912912
913913 #endregion
914+
915+ #region Leading digit provider name tests
916+
917+ [ Fact ]
918+ public void LeadingDigitProvider_ClassNamePrefixedWithUnderscore ( )
919+ {
920+ string content = GenerateParserFromManifest ( "LeadingDigitProvider.manifest.xml" ) ;
921+
922+ // Provider "3Scale-ETW-Provider" → ToCSharpName → "_3ScaleETWProvider"
923+ // C# identifiers cannot start with a digit, so an underscore is prepended.
924+ Assert . Contains ( "public sealed class _3ScaleETWProviderTraceEventParser : TraceEventParser" , content ) ;
925+ }
926+
927+ #endregion
914928 }
915929}
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <instrumentationManifest xmlns =" http://schemas.microsoft.com/win/2004/08/events" >
3+ <instrumentation xmlns : xs =" http://www.w3.org/2001/XMLSchema"
4+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5+ xmlns : win =" http://manifests.microsoft.com/win/2004/08/windows/events" >
6+
7+ <events xmlns =" http://schemas.microsoft.com/win/2004/08/events" >
8+ <!-- Provider name starts with a digit to test ToCSharpName leading-digit fix -->
9+ <provider name =" 3Scale-ETW-Provider"
10+ guid =" {DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF}"
11+ symbol =" THREE_SCALE_ETW_PROVIDER"
12+ messageFileName =" 3Scale.dll"
13+ resourceFileName =" 3Scale.dll" >
14+
15+ <tasks >
16+ <task name =" Request" value =" 1" />
17+ </tasks >
18+
19+ <templates >
20+ <template tid =" RequestArgs" >
21+ <data name =" Url" inType =" win:UnicodeString" />
22+ </template >
23+ </templates >
24+
25+ <events >
26+ <event value =" 1"
27+ symbol =" Request"
28+ task =" Request"
29+ template =" RequestArgs"
30+ level =" win:Informational" />
31+ </events >
32+
33+ </provider >
34+ </events >
35+ </instrumentation >
36+ </instrumentationManifest >
Original file line number Diff line number Diff line change @@ -1006,6 +1006,13 @@ public static string ToCSharpName(string input)
10061006
10071007 validName . Append ( c ) ;
10081008 }
1009+
1010+ // C# identifiers cannot start with a digit - prefix with underscore if needed.
1011+ if ( validName . Length > 0 && Char . IsDigit ( validName [ 0 ] ) )
1012+ {
1013+ validName . Insert ( 0 , '_' ) ;
1014+ }
1015+
10091016 return validName . ToString ( ) ;
10101017 }
10111018
You can’t perform that action at this time.
0 commit comments