@@ -969,57 +969,4 @@ public async Task WindowsUwp()
969969 await Assert . That ( resultUwp ) . Contains ( "netstandard_code" ) ;
970970 await Assert . That ( resultUwp ) . DoesNotContain ( "#if" ) ;
971971 }
972-
973- static void AssertNoFrameworkMonikers ( string content , string filePath , string targetFramework )
974- {
975- // Check for specific framework version symbols
976- var monikerPatterns = new [ ]
977- {
978- @"\bNET\d+_\d+\b" ,
979- @"\bNET\d+_\d+_OR_GREATER\b" ,
980- @"\bNETCOREAPP\d+_\d+\b" ,
981- @"\bNETCOREAPP\d+_\d+_OR_GREATER\b" ,
982- @"\bNETSTANDARD\d+_\d+\b" ,
983- @"\bNETSTANDARD\d+_\d+_OR_GREATER\b" ,
984- @"\bNETCOREAPP\d+X\b" ,
985- @"\bNET\d+X\b" ,
986- @"\bNETCOREAPPX\b" ,
987- @"\bNETFRAMEWORK\b" ,
988- @"\bNETSTANDARD\b(?!_)" ,
989- @"\bNETCOREAPP\b(?!_)" ,
990- @"\bWINDOWS_UWP\b"
991- } ;
992-
993- foreach ( var pattern in monikerPatterns )
994- {
995- var matches = Regex . Matches ( content , pattern ) ;
996- foreach ( Match match in matches )
997- {
998- // Check if it's inside a string literal or comment (which is OK)
999- var lineStart = content . LastIndexOf ( '\n ' , match . Index ) + 1 ;
1000- var lineEnd = content . IndexOf ( '\n ' , match . Index ) ;
1001- if ( lineEnd == - 1 ) lineEnd = content . Length ;
1002- var line = content . Substring ( lineStart , lineEnd - lineStart ) ;
1003-
1004- // Skip if it's in a comment
1005- if ( line . TrimStart ( ) . StartsWith ( "//" ) || line . Contains ( "/*" ) )
1006- {
1007- continue ;
1008- }
1009-
1010- // Skip if it's in a string literal (basic check)
1011- var posInLine = match . Index - lineStart ;
1012- var quotesBeforeMatch = line . Substring ( 0 , posInLine ) . Count ( c => c == '"' ) ;
1013- if ( quotesBeforeMatch % 2 == 1 )
1014- {
1015- continue ;
1016- }
1017-
1018- // This is a framework moniker in a preprocessor directive - fail
1019- throw new (
1020- $ "Framework moniker '{ match . Value } ' found in { filePath } for target framework { targetFramework } :\n " +
1021- $ "Line: { line . Trim ( ) } ") ;
1022- }
1023- }
1024- }
1025972}
0 commit comments