@@ -40,11 +40,11 @@ public class DscExamplesPresent : IDSCResourceRule
40
40
/// <returns>The results of the analysis</returns>
41
41
public IEnumerable < DiagnosticRecord > AnalyzeDSCResource ( Ast ast , string fileName )
42
42
{
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 ) ;
46
46
Boolean examplesPresent = false ;
47
- String expectedExamplesPath = fileName + " \\ .. \\ .. \\ .. \\ Examples";
47
+ String expectedExamplesPath = Path . Combine ( new String [ ] { fileName , ".." , ".." , ".." , " Examples"} ) ;
48
48
49
49
// Verify examples are present
50
50
if ( Directory . Exists ( expectedExamplesPath ) )
@@ -84,9 +84,9 @@ item is TypeDefinitionAst
84
84
{
85
85
resourceName = dscClass . Name ;
86
86
87
- String examplesQuery = "*" + resourceName + "*" ;
87
+ String examplesQuery = String . Format ( "*{0}*" , resourceName ) ;
88
88
Boolean examplesPresent = false ;
89
- String expectedExamplesPath = fileName + " \\ .. \\ Examples";
89
+ String expectedExamplesPath = Path . Combine ( new String [ ] { fileName , ".." , " Examples"} ) ;
90
90
91
91
// Verify examples are present
92
92
if ( Directory . Exists ( expectedExamplesPath ) )
0 commit comments