@@ -40,11 +40,11 @@ public class DscExamplesPresent : IDSCResourceRule
4040 /// <returns>The results of the analysis</returns>
4141 public IEnumerable < DiagnosticRecord > AnalyzeDSCResource ( Ast ast , string fileName )
4242 {
43- String fileNameOnly = fileName . Substring ( fileName . LastIndexOf ( " \\ " , StringComparison . Ordinal ) + 1 ) ;
44- String resourceName = fileNameOnly . Substring ( 0 , fileNameOnly . Length - ".psm1" . Length ) ;
45- String examplesQuery = "*" + resourceName + "*" ;
43+ String fileNameOnly = Path . GetFileName ( fileName ) ;
44+ String resourceName = Path . GetFileNameWithoutExtension ( fileNameOnly ) ;
45+ String examplesQuery = String . Format ( "*{0}*" , resourceName ) ;
4646 Boolean examplesPresent = false ;
47- String expectedExamplesPath = fileName + " \\ .. \\ .. \\ .. \\ Examples";
47+ String expectedExamplesPath = Path . Combine ( new String [ ] { fileName , ".." , ".." , ".." , " Examples"} ) ;
4848
4949 // Verify examples are present
5050 if ( Directory . Exists ( expectedExamplesPath ) )
@@ -84,9 +84,9 @@ item is TypeDefinitionAst
8484 {
8585 resourceName = dscClass . Name ;
8686
87- String examplesQuery = "*" + resourceName + "*" ;
87+ String examplesQuery = String . Format ( "*{0}*" , resourceName ) ;
8888 Boolean examplesPresent = false ;
89- String expectedExamplesPath = fileName + " \\ .. \\ Examples";
89+ String expectedExamplesPath = Path . Combine ( new String [ ] { fileName , ".." , " Examples"} ) ;
9090
9191 // Verify examples are present
9292 if ( Directory . Exists ( expectedExamplesPath ) )
0 commit comments