1+ //
2+ // Copyright (c) Microsoft Corporation.
3+ //
4+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
10+ // THE SOFTWARE.
11+ //
12+
13+ using System ;
14+ using System . Collections . Generic ;
15+ using System . Linq ;
16+ using System . Management . Automation . Language ;
17+ using Microsoft . Windows . Powershell . ScriptAnalyzer . Generic ;
18+ using System . ComponentModel . Composition ;
19+ using System . Globalization ;
20+ using System . IO ;
21+ using System . Management . Automation ;
22+
23+ namespace Microsoft . Windows . Powershell . ScriptAnalyzer . BuiltinRules
24+ {
25+ /// <summary>
26+ /// DscTestsPresent: Checks that DSC tests for given resource are present.
27+ /// Rule expects directory Tests to be present:
28+ /// For non-class based resources it should exist at the same folder level as DSCResources folder.
29+ /// For class based resources it should be present at the same folder level as resource psm1 file.
30+ /// Tests folder should contain test script for given resource - file name should contain resource's name.
31+ /// </summary>
32+ [ Export ( typeof ( IDSCResourceRule ) ) ]
33+ public class DscExamplesPresent : IDSCResourceRule
34+ {
35+ /// <summary>
36+ /// AnalyzeDSCResource: Analyzes given DSC Resource
37+ /// </summary>
38+ /// <param name="ast">The script's ast</param>
39+ /// <param name="fileName">The name of the script file being analyzed</param>
40+ /// <returns>The results of the analysis</returns>
41+ public IEnumerable < DiagnosticRecord > AnalyzeDSCResource ( Ast ast , string fileName )
42+ {
43+
44+ }
45+
46+ /// <summary>
47+ /// AnalyzeDSCClass: Analyzes given DSC class
48+ /// </summary>
49+ /// <param name="ast"></param>
50+ /// <param name="fileName"></param>
51+ /// <returns></returns>
52+ public IEnumerable < DiagnosticRecord > AnalyzeDSCClass ( Ast ast , string fileName )
53+ {
54+
55+ }
56+
57+ /// <summary>
58+ /// GetName: Retrieves the name of this rule.
59+ /// </summary>
60+ /// <returns>The name of this rule</returns>
61+ public string GetName ( )
62+ {
63+ return string . Format ( CultureInfo . CurrentCulture , Strings . NameSpaceFormat , GetSourceName ( ) , Strings . DscExamplesPresent ) ;
64+ }
65+
66+ /// <summary>
67+ /// GetCommonName: Retrieves the Common name of this rule.
68+ /// </summary>
69+ /// <returns>The common name of this rule</returns>
70+ public string GetCommonName ( )
71+ {
72+ return string . Format ( CultureInfo . CurrentCulture , Strings . DscExamplesPresentCommonName ) ;
73+ }
74+
75+ /// <summary>
76+ /// GetDescription: Retrieves the description of this rule.
77+ /// </summary>
78+ /// <returns>The description of this rule</returns>
79+ public string GetDescription ( )
80+ {
81+ return string . Format ( CultureInfo . CurrentCulture , Strings . DscExamplesPresentDescription ) ;
82+ }
83+
84+ /// <summary>
85+ /// GetSourceType: Retrieves the type of the rule: builtin, managed or module.
86+ /// </summary>
87+ public SourceType GetSourceType ( )
88+ {
89+ return SourceType . Builtin ;
90+ }
91+
92+ /// <summary>
93+ /// GetSeverity: Retrieves the severity of the rule: error, warning or information.
94+ /// </summary>
95+ /// <returns></returns>
96+ public RuleSeverity GetSeverity ( )
97+ {
98+ return RuleSeverity . Information ;
99+ }
100+
101+ /// <summary>
102+ /// GetSourceName: Retrieves the module/assembly name the rule is from.
103+ /// </summary>
104+ public string GetSourceName ( )
105+ {
106+ return string . Format ( CultureInfo . CurrentCulture , Strings . DSCSourceName ) ;
107+ }
108+ }
109+
110+ }
0 commit comments