diff --git a/.gitignore b/.gitignore index 329ec9bd5..15f683bf8 100644 --- a/.gitignore +++ b/.gitignore @@ -205,4 +205,7 @@ FakesAssemblies/ *.opt ##Our project binplace location -PSScriptAnalyzer/ \ No newline at end of file +PSScriptAnalyzer/ + +## generated resource files +gen/ diff --git a/Engine/Commands/GetScriptAnalyzerRuleCommand.cs b/Engine/Commands/GetScriptAnalyzerRuleCommand.cs index e60ff8500..b46d97c3b 100644 --- a/Engine/Commands/GetScriptAnalyzerRuleCommand.cs +++ b/Engine/Commands/GetScriptAnalyzerRuleCommand.cs @@ -111,7 +111,7 @@ protected override void ProcessRecord() IEnumerable rules = ScriptAnalyzer.Instance.GetRule(modNames, name); if (rules == null) { - WriteObject(string.Format(CultureInfo.CurrentCulture, Strings.RulesNotFound)); + WriteObject(string.Format(CultureInfo.CurrentCulture, EngineStrings.RulesNotFound)); } else { diff --git a/Engine/Commands/InvokeFormatterCommand.cs b/Engine/Commands/InvokeFormatterCommand.cs index 23d19284c..9e0430c5d 100644 --- a/Engine/Commands/InvokeFormatterCommand.cs +++ b/Engine/Commands/InvokeFormatterCommand.cs @@ -97,7 +97,7 @@ protected override void BeginProcessing() this.ThrowTerminatingError(new ErrorRecord( new ArgumentException(String.Format( CultureInfo.CurrentCulture, - Strings.SettingsNotParsable)), + EngineStrings.SettingsNotParsable)), "SETTINGS_ERROR", ErrorCategory.InvalidArgument, Settings)); diff --git a/Engine/Commands/InvokeScriptAnalyzerCommand.cs b/Engine/Commands/InvokeScriptAnalyzerCommand.cs index 723c540b9..66cf8f396 100644 --- a/Engine/Commands/InvokeScriptAnalyzerCommand.cs +++ b/Engine/Commands/InvokeScriptAnalyzerCommand.cs @@ -324,7 +324,7 @@ protected override void BeginProcessing() } catch { - this.WriteWarning(String.Format(CultureInfo.CurrentCulture, Strings.SettingsNotParsable)); + this.WriteWarning(String.Format(CultureInfo.CurrentCulture, EngineStrings.SettingsNotParsable)); stopProcessing = true; return; } @@ -363,7 +363,7 @@ protected override void ProcessRecord() this.WriteVerbose( String.Format( CultureInfo.CurrentCulture, - Strings.ModuleDepHandlerTempLocation, + EngineStrings.ModuleDepHandlerTempLocation, moduleHandler.TempModulePath)); ProcessInput(); } diff --git a/Engine/EditableText.cs b/Engine/EditableText.cs index 5d77862d2..b82171170 100644 --- a/Engine/EditableText.cs +++ b/Engine/EditableText.cs @@ -154,7 +154,7 @@ private void ValidateTextEditExtent(TextEdit textEdit) { throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, - Strings.EditableTextRangeIsNotContained)); + EngineStrings.EditableTextRangeIsNotContained)); } } @@ -183,7 +183,7 @@ private static int GetNumNewLineCharacters(string text, out string[] lines) if (remainder != 0) { throw new ArgumentException( - String.Format(CultureInfo.CurrentCulture, Strings.EditableTextInvalidLineEnding), + String.Format(CultureInfo.CurrentCulture, EngineStrings.EditableTextInvalidLineEnding), nameof(text)); } diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index 2981cf2f6..1fd0d9409 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -8,6 +8,10 @@ Microsoft.Windows.PowerShell.ScriptAnalyzer + + + + @@ -34,7 +38,8 @@ - + $(DefineConstants);PSV3;PSV5 diff --git a/Engine/Generic/ConfigurableRule.cs b/Engine/Generic/ConfigurableRule.cs index 427cf8067..55eb2b3c5 100644 --- a/Engine/Generic/ConfigurableRule.cs +++ b/Engine/Generic/ConfigurableRule.cs @@ -146,7 +146,7 @@ private Object GetDefaultValue(PropertyInfo property) if (attr == null) { throw new ArgumentException( - String.Format(Strings.ConfigurableScriptRulePropertyHasNotAttribute, property.Name), + String.Format(EngineStrings.ConfigurableScriptRulePropertyHasNotAttribute, property.Name), nameof(property)); } diff --git a/Engine/Generic/ConfigurableRulePropertyAttribute.cs b/Engine/Generic/ConfigurableRulePropertyAttribute.cs index d661aa225..a968fc9c5 100644 --- a/Engine/Generic/ConfigurableRulePropertyAttribute.cs +++ b/Engine/Generic/ConfigurableRulePropertyAttribute.cs @@ -31,7 +31,7 @@ public ConfigurableRulePropertyAttribute(object defaultValue) { if (defaultValue == null) { - throw new ArgumentNullException(nameof(defaultValue), Strings.ConfigurableScriptRuleNRE); + throw new ArgumentNullException(nameof(defaultValue), EngineStrings.ConfigurableScriptRuleNRE); } DefaultValue = defaultValue; diff --git a/Engine/Generic/RuleSuppression.cs b/Engine/Generic/RuleSuppression.cs index 2cfee6311..9f0ab50f7 100644 --- a/Engine/Generic/RuleSuppression.cs +++ b/Engine/Generic/RuleSuppression.cs @@ -77,7 +77,7 @@ public string RuleName && (ScriptAnalyzer.Instance.DSCResourceRules != null && ScriptAnalyzer.Instance.DSCResourceRules.Count(item => String.Equals(item.GetName(), _ruleName, StringComparison.OrdinalIgnoreCase)) == 0)) { - Error = String.Format(Strings.RuleSuppressionRuleNameNotFound, _ruleName); + Error = String.Format(EngineStrings.RuleSuppressionRuleNameNotFound, _ruleName); } } } @@ -164,7 +164,7 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) if (positionalArguments.Any(item => !(item is StringConstantExpressionAst))) { - Error = Strings.StringConstantArgumentsSuppressionAttributeError; + Error = EngineStrings.StringConstantArgumentsSuppressionAttributeError; } else { @@ -202,12 +202,12 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) { if (name.Extent.StartOffset < lastPositionalArgumentsOffset) { - Error = Strings.NamedArgumentsBeforePositionalError; + Error = EngineStrings.NamedArgumentsBeforePositionalError; break; } else if (!(name.Argument is StringConstantExpressionAst)) { - Error = Strings.StringConstantArgumentsSuppressionAttributeError; + Error = EngineStrings.StringConstantArgumentsSuppressionAttributeError; break; } @@ -216,7 +216,7 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) case "rulename": if (!String.IsNullOrWhiteSpace(RuleName)) { - Error = String.Format(Strings.NamedAndPositionalArgumentsConflictError, name); + Error = String.Format(EngineStrings.NamedAndPositionalArgumentsConflictError, name); } RuleName = (name.Argument as StringConstantExpressionAst).Value; @@ -225,7 +225,7 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) case "rulesuppressionid": if (!String.IsNullOrWhiteSpace(RuleSuppressionID)) { - Error = String.Format(Strings.NamedAndPositionalArgumentsConflictError, name); + Error = String.Format(EngineStrings.NamedAndPositionalArgumentsConflictError, name); } RuleSuppressionID = (name.Argument as StringConstantExpressionAst).Value; @@ -234,14 +234,14 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) case "scope": if (!String.IsNullOrWhiteSpace(Scope)) { - Error = String.Format(Strings.NamedAndPositionalArgumentsConflictError, name); + Error = String.Format(EngineStrings.NamedAndPositionalArgumentsConflictError, name); } Scope = (name.Argument as StringConstantExpressionAst).Value; if (!scopeSet.Contains(Scope)) { - Error = Strings.WrongScopeArgumentSuppressionAttributeError; + Error = EngineStrings.WrongScopeArgumentSuppressionAttributeError; } goto default; @@ -249,7 +249,7 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) case "target": if (!String.IsNullOrWhiteSpace(Target)) { - Error = String.Format(Strings.NamedAndPositionalArgumentsConflictError, name); + Error = String.Format(EngineStrings.NamedAndPositionalArgumentsConflictError, name); } Target = (name.Argument as StringConstantExpressionAst).Value; @@ -258,7 +258,7 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) case "justification": if (!String.IsNullOrWhiteSpace(Justification)) { - Error = String.Format(Strings.NamedAndPositionalArgumentsConflictError, name); + Error = String.Format(EngineStrings.NamedAndPositionalArgumentsConflictError, name); } Justification = (name.Argument as StringConstantExpressionAst).Value; @@ -279,13 +279,13 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) else if (String.IsNullOrWhiteSpace(RuleName)) { RuleName = String.Empty; - Error = Strings.NullRuleNameError; + Error = EngineStrings.NullRuleNameError; } // Must have scope and target together if (String.IsNullOrWhiteSpace(Scope) && !String.IsNullOrWhiteSpace(Target)) { - Error = Strings.TargetWithoutScopeSuppressionAttributeError; + Error = EngineStrings.TargetWithoutScopeSuppressionAttributeError; } } @@ -296,11 +296,11 @@ public RuleSuppression(AttributeAst attrAst, int start, int end) { if (String.IsNullOrWhiteSpace(attrAst.Extent.File)) { - Error = String.Format(CultureInfo.CurrentCulture, Strings.RuleSuppressionErrorFormatScriptDefinition, StartAttributeLine, Error); + Error = String.Format(CultureInfo.CurrentCulture, EngineStrings.RuleSuppressionErrorFormatScriptDefinition, StartAttributeLine, Error); } else { - Error = String.Format(CultureInfo.CurrentCulture, Strings.RuleSuppressionErrorFormat, StartAttributeLine, + Error = String.Format(CultureInfo.CurrentCulture, EngineStrings.RuleSuppressionErrorFormat, StartAttributeLine, System.IO.Path.GetFileName(attrAst.Extent.File), Error); } } @@ -387,13 +387,13 @@ public static List GetSuppressions(IEnumerable at { if (String.IsNullOrWhiteSpace(scopeAst.Extent.File)) { - ruleSupp.Error = String.Format(CultureInfo.CurrentCulture, Strings.RuleSuppressionErrorFormatScriptDefinition, ruleSupp.StartAttributeLine, - String.Format(Strings.TargetCannotBeFoundError, ruleSupp.Target, ruleSupp.Scope)); + ruleSupp.Error = String.Format(CultureInfo.CurrentCulture, EngineStrings.RuleSuppressionErrorFormatScriptDefinition, ruleSupp.StartAttributeLine, + String.Format(EngineStrings.TargetCannotBeFoundError, ruleSupp.Target, ruleSupp.Scope)); } else { - ruleSupp.Error = String.Format(CultureInfo.CurrentCulture, Strings.RuleSuppressionErrorFormat, ruleSupp.StartAttributeLine, - System.IO.Path.GetFileName(scopeAst.Extent.File), String.Format(Strings.TargetCannotBeFoundError, ruleSupp.Target, ruleSupp.Scope)); + ruleSupp.Error = String.Format(CultureInfo.CurrentCulture, EngineStrings.RuleSuppressionErrorFormat, ruleSupp.StartAttributeLine, + System.IO.Path.GetFileName(scopeAst.Extent.File), String.Format(EngineStrings.TargetCannotBeFoundError, ruleSupp.Target, ruleSupp.Scope)); } result.Add(ruleSupp); diff --git a/Engine/Helper.cs b/Engine/Helper.cs index 31120ed99..abdcf40a2 100644 --- a/Engine/Helper.cs +++ b/Engine/Helper.cs @@ -1467,13 +1467,13 @@ public Tuple, List> SuppressRule( // checks whether are given a string or a file path if (String.IsNullOrWhiteSpace(diagnostics.First().Extent.File)) { - ruleSuppression.Error = String.Format(CultureInfo.CurrentCulture, Strings.RuleSuppressionErrorFormatScriptDefinition, ruleSuppression.StartAttributeLine, - String.Format(Strings.RuleSuppressionIDError, ruleSuppression.RuleSuppressionID)); + ruleSuppression.Error = String.Format(CultureInfo.CurrentCulture, EngineStrings.RuleSuppressionErrorFormatScriptDefinition, ruleSuppression.StartAttributeLine, + String.Format(EngineStrings.RuleSuppressionIDError, ruleSuppression.RuleSuppressionID)); } else { - ruleSuppression.Error = String.Format(CultureInfo.CurrentCulture, Strings.RuleSuppressionErrorFormat, ruleSuppression.StartAttributeLine, - System.IO.Path.GetFileName(diagnostics.First().Extent.File), String.Format(Strings.RuleSuppressionIDError, ruleSuppression.RuleSuppressionID)); + ruleSuppression.Error = String.Format(CultureInfo.CurrentCulture, EngineStrings.RuleSuppressionErrorFormat, ruleSuppression.StartAttributeLine, + System.IO.Path.GetFileName(diagnostics.First().Extent.File), String.Format(EngineStrings.RuleSuppressionIDError, ruleSuppression.RuleSuppressionID)); } errorRecords.Add(new ErrorRecord(new ArgumentException(ruleSuppression.Error), ruleSuppression.Error, ErrorCategory.InvalidArgument, ruleSuppression)); //this.outputWriter.WriteError(new ErrorRecord(new ArgumentException(ruleSuppression.Error), ruleSuppression.Error, ErrorCategory.InvalidArgument, ruleSuppression)); @@ -3739,7 +3739,7 @@ public void AddVertex(T vertex) { throw new ArgumentException( String.Format( - Strings.DigraphVertexAlreadyExists, + EngineStrings.DigraphVertexAlreadyExists, vertex), "vertex"); } @@ -3766,7 +3766,7 @@ public void AddEdge(T fromVertex, T toVertex) if (fromVertexList.Contains(toIdx)) { throw new ArgumentException(String.Format( - Strings.DigraphEdgeAlreadyExists, + EngineStrings.DigraphEdgeAlreadyExists, fromVertex.ToString(), toVertex.ToString())); } @@ -3840,7 +3840,7 @@ private void ValidateVertexPresence(T vertex) { throw new ArgumentOutOfRangeException( String.Format( - Strings.DigraphVertexDoesNotExists, + EngineStrings.DigraphVertexDoesNotExists, vertex.ToString()), "vertex"); } diff --git a/Engine/Position.cs b/Engine/Position.cs index 8be30cfd0..9a607f747 100644 --- a/Engine/Position.cs +++ b/Engine/Position.cs @@ -18,14 +18,14 @@ public Position(int line, int column) if (line < 1) { throw new ArgumentException( - String.Format(CultureInfo.CurrentCulture, Strings.PositionLineLessThanOne), + String.Format(CultureInfo.CurrentCulture, EngineStrings.PositionLineLessThanOne), nameof(line)); } if (column < 1) { throw new ArgumentException( - String.Format(CultureInfo.CurrentCulture, Strings.PositionColumnLessThanOne), + String.Format(CultureInfo.CurrentCulture, EngineStrings.PositionColumnLessThanOne), nameof(column)); } @@ -73,7 +73,7 @@ public Position Shift(int lineDelta, int columnDelta) if (newLine < 1) { throw new ArgumentException( - String.Format(CultureInfo.CurrentCulture, Strings.PositionLineLessThanOne), + String.Format(CultureInfo.CurrentCulture, EngineStrings.PositionLineLessThanOne), nameof(lineDelta)); } @@ -81,7 +81,7 @@ public Position Shift(int lineDelta, int columnDelta) if (newColumn < 1) { throw new ArgumentException( - String.Format(CultureInfo.CurrentCulture, Strings.PositionColumnLessThanOne), + String.Format(CultureInfo.CurrentCulture, EngineStrings.PositionColumnLessThanOne), nameof(columnDelta)); } @@ -110,7 +110,7 @@ public static Position Normalize(Position refPos, Position pos) { throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, - Strings.PositionRefPosLessThanInputPos)); + EngineStrings.PositionRefPosLessThanInputPos)); } if (pos.Line == refPos.Line) diff --git a/Engine/Range.cs b/Engine/Range.cs index 7f63caaf6..6b8f4579c 100644 --- a/Engine/Range.cs +++ b/Engine/Range.cs @@ -85,7 +85,7 @@ public static Range Normalize(Position refPosition, Range range) { throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, - Strings.RangeRefPosShouldStartBeforeRangeStartPos)); + EngineStrings.RangeRefPosShouldStartBeforeRangeStartPos)); } return range.Shift( @@ -109,7 +109,7 @@ private void ValidatePositions() { throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, - Strings.RangeStartPosGreaterThanEndPos)); + EngineStrings.RangeStartPosGreaterThanEndPos)); } } } diff --git a/Engine/ScriptAnalyzer.cs b/Engine/ScriptAnalyzer.cs index cdc3884f5..308086f11 100644 --- a/Engine/ScriptAnalyzer.cs +++ b/Engine/ScriptAnalyzer.cs @@ -328,11 +328,11 @@ private Dictionary GetDictionaryFromHashTableAst( new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongKeyFormat, + EngineStrings.WrongKeyFormat, kvp.Item1.Extent.StartLineNumber, kvp.Item1.Extent.StartColumnNumber, profile)), - Strings.ConfigurationKeyNotAString, + EngineStrings.ConfigurationKeyNotAString, ErrorCategory.InvalidData, profile)); hasError = true; @@ -399,11 +399,11 @@ private Dictionary GetDictionaryFromHashTableAst( new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongValueFormat, + EngineStrings.WrongValueFormat, element.Extent.StartLineNumber, element.Extent.StartColumnNumber, "")), - Strings.ConfigurationValueNotAString, + EngineStrings.ConfigurationValueNotAString, ErrorCategory.InvalidData, null)); hasError = true; @@ -423,11 +423,11 @@ private Dictionary GetDictionaryFromHashTableAst( new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongValueFormat, + EngineStrings.WrongValueFormat, kvp.Item2.Extent.StartLineNumber, kvp.Item2.Extent.StartColumnNumber, profile)), - Strings.ConfigurationValueWrongFormat, + EngineStrings.ConfigurationValueWrongFormat, ErrorCategory.InvalidData, profile)); hasError = true; @@ -457,8 +457,8 @@ private Dictionary GetDictionaryFromHashtable( { writer.WriteError( new ErrorRecord( - new InvalidDataException(string.Format(CultureInfo.CurrentCulture, Strings.KeyNotString, key)), - Strings.ConfigurationKeyNotAString, + new InvalidDataException(string.Format(CultureInfo.CurrentCulture, EngineStrings.KeyNotString, key)), + EngineStrings.ConfigurationKeyNotAString, ErrorCategory.InvalidData, hashtable)); hasError = true; @@ -469,8 +469,8 @@ private Dictionary GetDictionaryFromHashtable( { writer.WriteError( new ErrorRecord( - new InvalidDataException(string.Format(CultureInfo.CurrentCulture, Strings.WrongValueHashTable, valueHashtableObj, key)), - Strings.WrongConfigurationKey, + new InvalidDataException(string.Format(CultureInfo.CurrentCulture, EngineStrings.WrongValueHashTable, valueHashtableObj, key)), + EngineStrings.WrongConfigurationKey, ErrorCategory.InvalidData, hashtable)); hasError = true; @@ -534,8 +534,8 @@ private bool ParseProfileHashtable(Hashtable profile, PathIntrinsics path, IOutp { writer.WriteError( new ErrorRecord( - new InvalidDataException(string.Format(CultureInfo.CurrentCulture, Strings.WrongValueHashTable, value, key)), - Strings.WrongConfigurationKey, + new InvalidDataException(string.Format(CultureInfo.CurrentCulture, EngineStrings.WrongValueHashTable, value, key)), + EngineStrings.WrongConfigurationKey, ErrorCategory.InvalidData, profile)); hasError = true; @@ -563,8 +563,8 @@ private bool ParseProfileHashtable(Hashtable profile, PathIntrinsics path, IOutp { writer.WriteError( new ErrorRecord( - new InvalidDataException(string.Format(CultureInfo.CurrentCulture, Strings.WrongValueHashTable, val, key)), - Strings.WrongConfigurationKey, + new InvalidDataException(string.Format(CultureInfo.CurrentCulture, EngineStrings.WrongValueHashTable, val, key)), + EngineStrings.WrongConfigurationKey, ErrorCategory.InvalidData, profile)); hasError = true; @@ -582,8 +582,8 @@ private bool ParseProfileHashtable(Hashtable profile, PathIntrinsics path, IOutp default: writer.WriteError( new ErrorRecord( - new InvalidDataException(string.Format(CultureInfo.CurrentCulture, Strings.WrongKeyHashTable, key)), - Strings.WrongConfigurationKey, + new InvalidDataException(string.Format(CultureInfo.CurrentCulture, EngineStrings.WrongKeyHashTable, key)), + EngineStrings.WrongConfigurationKey, ErrorCategory.InvalidData, profile)); hasError = true; @@ -604,8 +604,8 @@ private bool ParseProfileString(string profile, PathIntrinsics path, IOutputWrit } catch { - writer.WriteError(new ErrorRecord(new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Strings.FileNotFound, profile)), - Strings.ConfigurationFileNotFound, ErrorCategory.ResourceUnavailable, profile)); + writer.WriteError(new ErrorRecord(new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, EngineStrings.FileNotFound, profile)), + EngineStrings.ConfigurationFileNotFound, ErrorCategory.ResourceUnavailable, profile)); hasError = true; } @@ -619,8 +619,8 @@ private bool ParseProfileString(string profile, PathIntrinsics path, IOutputWrit // no hashtable, raise warning if (hashTableAsts.Count() == 0) { - writer.WriteError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.InvalidProfile, profile)), - Strings.ConfigurationFileHasNoHashTable, ErrorCategory.ResourceUnavailable, profile)); + writer.WriteError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, EngineStrings.InvalidProfile, profile)), + EngineStrings.ConfigurationFileHasNoHashTable, ErrorCategory.ResourceUnavailable, profile)); hasError = true; } else @@ -646,10 +646,10 @@ private bool ParseProfileString(string profile, PathIntrinsics path, IOutputWrit new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongKey, + EngineStrings.WrongKey, key, profile)), - Strings.WrongConfigurationKey, + EngineStrings.WrongConfigurationKey, ErrorCategory.InvalidData, profile)); hasError = true; @@ -666,8 +666,8 @@ private bool ParseProfileString(string profile, PathIntrinsics path, IOutputWrit { writer.WriteError( new ErrorRecord( - new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.InvalidProfile, profile)), - Strings.ConfigurationFileHasInvalidHashtable, + new ArgumentException(string.Format(CultureInfo.CurrentCulture, EngineStrings.InvalidProfile, profile)), + EngineStrings.ConfigurationFileHasInvalidHashtable, ErrorCategory.ResourceUnavailable, profile)); hasError = true; @@ -831,7 +831,7 @@ private void Initialize( new Exception(), string.Format( CultureInfo.CurrentCulture, - Strings.RulesNotFound), + EngineStrings.RulesNotFound), ErrorCategory.ResourceExists, this)); } @@ -854,7 +854,7 @@ private List GetValidCustomRulePaths(string[] customizedRulePath, PathIn this.validationResults = this.CheckRuleExtension(paths.ToArray(), path); foreach (string extension in this.validationResults["InvalidPaths"]) { - this.outputWriter.WriteWarning(string.Format(CultureInfo.CurrentCulture, Strings.MissingRuleExtension, extension)); + this.outputWriter.WriteWarning(string.Format(CultureInfo.CurrentCulture, EngineStrings.MissingRuleExtension, extension)); } } else @@ -1335,7 +1335,7 @@ public Dictionary> CheckRuleExtension(string[] path, PathIn { try { - this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, Strings.CheckModuleName, childPath)); + this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, EngineStrings.CheckModuleName, childPath)); string resolvedPath = string.Empty; @@ -1389,7 +1389,7 @@ public Dictionary> CheckRuleExtension(string[] path, PathIn string resolvedPath = basePath .GetResolvedPSPathFromPSPath(childPath).First().ToString(); - this.outputWriter.WriteDebug(string.Format(CultureInfo.CurrentCulture, Strings.CheckAssemblyFile, resolvedPath)); + this.outputWriter.WriteDebug(string.Format(CultureInfo.CurrentCulture, EngineStrings.CheckAssemblyFile, resolvedPath)); if (String.Equals(Path.GetExtension(resolvedPath), ".dll", StringComparison.OrdinalIgnoreCase)) { @@ -1520,7 +1520,7 @@ public IEnumerable AnalyzeScriptDefinition(string scriptDefini Token[] scriptTokens = null; ParseError[] errors = null; - this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, Strings.VerboseScriptDefinitionMessage)); + this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, EngineStrings.VerboseScriptDefinitionMessage)); try { @@ -1536,14 +1536,14 @@ public IEnumerable AnalyzeScriptDefinition(string scriptDefini { foreach (ParseError error in errors) { - string parseErrorMessage = String.Format(CultureInfo.CurrentCulture, Strings.ParseErrorFormatForScriptDefinition, error.Message.TrimEnd('.'), error.Extent.StartLineNumber, error.Extent.StartColumnNumber); + string parseErrorMessage = String.Format(CultureInfo.CurrentCulture, EngineStrings.ParseErrorFormatForScriptDefinition, error.Message.TrimEnd('.'), error.Extent.StartLineNumber, error.Extent.StartColumnNumber); this.outputWriter.WriteError(new ErrorRecord(new ParseException(parseErrorMessage), parseErrorMessage, ErrorCategory.ParserError, error.ErrorId)); } } if (errors != null && errors.Length > 10) { - string manyParseErrorMessage = String.Format(CultureInfo.CurrentCulture, Strings.ParserErrorMessageForScriptDefinition); + string manyParseErrorMessage = String.Format(CultureInfo.CurrentCulture, EngineStrings.ParserErrorMessageForScriptDefinition); this.outputWriter.WriteError(new ErrorRecord(new ParseException(manyParseErrorMessage), manyParseErrorMessage, ErrorCategory.ParserError, scriptDefinition)); return new List(); @@ -1705,7 +1705,7 @@ private List ScriptPathList(string path, bool searchRecursively) this.outputWriter.ThrowTerminatingError( new ErrorRecord( new FileNotFoundException(), - string.Format(CultureInfo.CurrentCulture, Strings.FileNotFound, path), + string.Format(CultureInfo.CurrentCulture, EngineStrings.FileNotFound, path), ErrorCategory.InvalidArgument, this)); } @@ -1767,7 +1767,7 @@ private void BuildScriptPathList( this.outputWriter.WriteError( new ErrorRecord( new FileNotFoundException(), - string.Format(CultureInfo.CurrentCulture, Strings.FileNotFound, path), + string.Format(CultureInfo.CurrentCulture, EngineStrings.FileNotFound, path), ErrorCategory.InvalidArgument, this)); } @@ -1815,7 +1815,7 @@ private IEnumerable AnalyzeFile(string filePath) Token[] scriptTokens = null; ParseError[] errors = null; - this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, Strings.VerboseFileMessage, filePath)); + this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, EngineStrings.VerboseFileMessage, filePath)); //Parse the file if (File.Exists(filePath)) @@ -1844,14 +1844,14 @@ private IEnumerable AnalyzeFile(string filePath) { foreach (ParseError error in errors) { - string parseErrorMessage = String.Format(CultureInfo.CurrentCulture, Strings.ParserErrorFormat, error.Extent.File, error.Message.TrimEnd('.'), error.Extent.StartLineNumber, error.Extent.StartColumnNumber); + string parseErrorMessage = String.Format(CultureInfo.CurrentCulture, EngineStrings.ParserErrorFormat, error.Extent.File, error.Message.TrimEnd('.'), error.Extent.StartLineNumber, error.Extent.StartColumnNumber); this.outputWriter.WriteError(new ErrorRecord(new ParseException(parseErrorMessage), parseErrorMessage, ErrorCategory.ParserError, error.ErrorId)); } } if (errors != null && errors.Length > 10) { - string manyParseErrorMessage = String.Format(CultureInfo.CurrentCulture, Strings.ParserErrorMessage, System.IO.Path.GetFileName(filePath)); + string manyParseErrorMessage = String.Format(CultureInfo.CurrentCulture, EngineStrings.ParserErrorMessage, System.IO.Path.GetFileName(filePath)); this.outputWriter.WriteError(new ErrorRecord(new ParseException(manyParseErrorMessage), manyParseErrorMessage, ErrorCategory.ParserError, filePath)); return new List(); } @@ -1860,7 +1860,7 @@ private IEnumerable AnalyzeFile(string filePath) else { this.outputWriter.ThrowTerminatingError(new ErrorRecord(new FileNotFoundException(), - string.Format(CultureInfo.CurrentCulture, Strings.InvalidPath, filePath), + string.Format(CultureInfo.CurrentCulture, EngineStrings.InvalidPath, filePath), ErrorCategory.InvalidArgument, filePath)); return null; @@ -2053,7 +2053,7 @@ public IEnumerable AnalyzeSyntaxTree( { bool helpRule = String.Equals(scriptRule.GetName(), "PSUseUTF8EncodingForHelpFile", StringComparison.OrdinalIgnoreCase); List result = new List(); - result.Add(string.Format(CultureInfo.CurrentCulture, Strings.VerboseRunningMessage, scriptRule.GetName())); + result.Add(string.Format(CultureInfo.CurrentCulture, EngineStrings.VerboseRunningMessage, scriptRule.GetName())); // Ensure that any unhandled errors from Rules are converted to non-terminating errors // We want the Engine to continue functioning even if one or more Rules throws an exception @@ -2089,7 +2089,7 @@ public IEnumerable AnalyzeSyntaxTree( } catch (Exception scriptRuleException) { - result.Add(new ErrorRecord(scriptRuleException, Strings.RuleErrorMessage, ErrorCategory.InvalidOperation, scriptAst.Extent.File)); + result.Add(new ErrorRecord(scriptRuleException, EngineStrings.RuleErrorMessage, ErrorCategory.InvalidOperation, scriptAst.Extent.File)); } verboseOrErrors.Add(result); @@ -2129,7 +2129,7 @@ public IEnumerable AnalyzeSyntaxTree( { if (IsRuleAllowed(tokenRule)) { - this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, Strings.VerboseRunningMessage, tokenRule.GetName())); + this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, EngineStrings.VerboseRunningMessage, tokenRule.GetName())); // Ensure that any unhandled errors from Rules are converted to non-terminating errors // We want the Engine to continue functioning even if one or more Rules throws an exception @@ -2148,7 +2148,7 @@ public IEnumerable AnalyzeSyntaxTree( } catch (Exception tokenRuleException) { - this.outputWriter.WriteError(new ErrorRecord(tokenRuleException, Strings.RuleErrorMessage, ErrorCategory.InvalidOperation, fileName)); + this.outputWriter.WriteError(new ErrorRecord(tokenRuleException, EngineStrings.RuleErrorMessage, ErrorCategory.InvalidOperation, fileName)); } } } @@ -2167,7 +2167,7 @@ public IEnumerable AnalyzeSyntaxTree( { if (IsRuleAllowed(dscResourceRule)) { - this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, Strings.VerboseRunningMessage, dscResourceRule.GetName())); + this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, EngineStrings.VerboseRunningMessage, dscResourceRule.GetName())); // Ensure that any unhandled errors from Rules are converted to non-terminating errors // We want the Engine to continue functioning even if one or more Rules throws an exception @@ -2195,7 +2195,7 @@ public IEnumerable AnalyzeSyntaxTree( } catch (Exception dscResourceRuleException) { - this.outputWriter.WriteError(new ErrorRecord(dscResourceRuleException, Strings.RuleErrorMessage, ErrorCategory.InvalidOperation, filePath)); + this.outputWriter.WriteError(new ErrorRecord(dscResourceRuleException, EngineStrings.RuleErrorMessage, ErrorCategory.InvalidOperation, filePath)); } } } @@ -2209,7 +2209,7 @@ public IEnumerable AnalyzeSyntaxTree( { if (IsRuleAllowed(dscResourceRule)) { - this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, Strings.VerboseRunningMessage, dscResourceRule.GetName())); + this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, EngineStrings.VerboseRunningMessage, dscResourceRule.GetName())); // Ensure that any unhandled errors from Rules are converted to non-terminating errors // We want the Engine to continue functioning even if one or more Rules throws an exception @@ -2228,7 +2228,7 @@ public IEnumerable AnalyzeSyntaxTree( } catch (Exception dscResourceRuleException) { - this.outputWriter.WriteError(new ErrorRecord(dscResourceRuleException, Strings.RuleErrorMessage, ErrorCategory.InvalidOperation, filePath)); + this.outputWriter.WriteError(new ErrorRecord(dscResourceRuleException, EngineStrings.RuleErrorMessage, ErrorCategory.InvalidOperation, filePath)); } } } @@ -2248,7 +2248,7 @@ public IEnumerable AnalyzeSyntaxTree( if (IsRuleAllowed(exRule)) { string ruleName = string.Format(CultureInfo.CurrentCulture, "{0}\\{1}", exRule.GetSourceName(), exRule.GetName()); - this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, Strings.VerboseRunningMessage, ruleName)); + this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, EngineStrings.VerboseRunningMessage, ruleName)); // Ensure that any unhandled errors from Rules are converted to non-terminating errors // We want the Engine to continue functioning even if one or more Rules throws an exception @@ -2258,7 +2258,7 @@ public IEnumerable AnalyzeSyntaxTree( } catch (Exception externalRuleException) { - this.outputWriter.WriteError(new ErrorRecord(externalRuleException, Strings.RuleErrorMessage, ErrorCategory.InvalidOperation, fileName)); + this.outputWriter.WriteError(new ErrorRecord(externalRuleException, EngineStrings.RuleErrorMessage, ErrorCategory.InvalidOperation, fileName)); } } } diff --git a/Engine/Settings.cs b/Engine/Settings.cs index 35a941781..59c04f5b3 100644 --- a/Engine/Settings.cs +++ b/Engine/Settings.cs @@ -80,7 +80,7 @@ public Settings(object settings, Func presetResolver) throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, - Strings.InvalidPath, + EngineStrings.InvalidPath, settingsFilePath)); } } @@ -93,7 +93,7 @@ public Settings(object settings, Func presetResolver) } else { - throw new ArgumentException(Strings.SettingsInvalidType); + throw new ArgumentException(EngineStrings.SettingsInvalidType); } } } @@ -191,12 +191,12 @@ internal static Settings Create(object settingsObj, string cwd, IOutputWriter ou outputWriter?.WriteVerbose( String.Format( CultureInfo.CurrentCulture, - Strings.SettingsNotProvided, + EngineStrings.SettingsNotProvided, "")); outputWriter?.WriteVerbose( String.Format( CultureInfo.CurrentCulture, - Strings.SettingsAutoDiscovered, + EngineStrings.SettingsAutoDiscovered, (string)settingsFound)); break; @@ -210,7 +210,7 @@ internal static Settings Create(object settingsObj, string cwd, IOutputWriter ou outputWriter?.WriteVerbose( String.Format( CultureInfo.CurrentCulture, - Strings.SettingsUsingFile, + EngineStrings.SettingsUsingFile, resolvedPath)); } catch @@ -218,7 +218,7 @@ internal static Settings Create(object settingsObj, string cwd, IOutputWriter ou outputWriter?.WriteVerbose( String.Format( CultureInfo.CurrentCulture, - Strings.SettingsCannotFindFile, + EngineStrings.SettingsCannotFindFile, userProvidedSettingsString)); } break; @@ -227,14 +227,14 @@ internal static Settings Create(object settingsObj, string cwd, IOutputWriter ou outputWriter?.WriteVerbose( String.Format( CultureInfo.CurrentCulture, - Strings.SettingsUsingHashtable)); + EngineStrings.SettingsUsingHashtable)); break; default: outputWriter?.WriteVerbose( String.Format( CultureInfo.CurrentCulture, - Strings.SettingsObjectCouldNotBResolved)); + EngineStrings.SettingsObjectCouldNotBResolved)); return null; } @@ -257,7 +257,7 @@ private Dictionary GetDictionaryFromHashtable(Hashtable hashtabl throw new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.KeyNotString, + EngineStrings.KeyNotString, key)); } @@ -267,7 +267,7 @@ private Dictionary GetDictionaryFromHashtable(Hashtable hashtabl throw new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongValueHashTable, + EngineStrings.WrongValueHashTable, "", key)); } @@ -304,7 +304,7 @@ private List GetData(object val, string key) throw new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongValueHashTable, + EngineStrings.WrongValueHashTable, "", key)); } @@ -338,7 +338,7 @@ private List GetData(object val, string key) throw new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongValueHashTable, + EngineStrings.WrongValueHashTable, val, key)); } @@ -349,7 +349,7 @@ private List GetData(object val, string key) throw new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongValueHashTable, + EngineStrings.WrongValueHashTable, val, key)); } @@ -367,12 +367,12 @@ private Dictionary> ConvertToRuleArgumentType var ruleArgs = ruleArguments as Dictionary; if (ruleArgs == null) { - throw new ArgumentException(Strings.SettingsInputShouldBeDictionary, nameof(ruleArguments)); + throw new ArgumentException(EngineStrings.SettingsInputShouldBeDictionary, nameof(ruleArguments)); } if (ruleArgs.Comparer != StringComparer.OrdinalIgnoreCase) { - throw new ArgumentException(Strings.SettingsDictionaryShouldBeCaseInsesitive, nameof(ruleArguments)); + throw new ArgumentException(EngineStrings.SettingsDictionaryShouldBeCaseInsesitive, nameof(ruleArguments)); } var ruleArgsDict = new Dictionary>(StringComparer.OrdinalIgnoreCase); @@ -381,7 +381,7 @@ private Dictionary> ConvertToRuleArgumentType var argsDict = ruleArgs[rule] as Dictionary; if (argsDict == null) { - throw new InvalidDataException(Strings.SettingsInputShouldBeDictionary); + throw new InvalidDataException(EngineStrings.SettingsInputShouldBeDictionary); } ruleArgsDict[rule] = argsDict; } @@ -421,7 +421,7 @@ private void parseSettingsHashtable(Hashtable settingsHashtable) { throw new InvalidDataException(string.Format( CultureInfo.CurrentCulture, - Strings.SettingsValueTypeMustBeBool, + EngineStrings.SettingsValueTypeMustBeBool, settingKey)); } @@ -440,7 +440,7 @@ private void parseSettingsHashtable(Hashtable settingsHashtable) catch (ArgumentException argumentException) { throw new InvalidDataException( - string.Format(CultureInfo.CurrentCulture, Strings.WrongValueHashTable, "", key), + string.Format(CultureInfo.CurrentCulture, EngineStrings.WrongValueHashTable, "", key), argumentException); } @@ -450,7 +450,7 @@ private void parseSettingsHashtable(Hashtable settingsHashtable) throw new InvalidDataException( string.Format( CultureInfo.CurrentCulture, - Strings.WrongKeyHashTable, + EngineStrings.WrongKeyHashTable, key)); } } @@ -466,7 +466,7 @@ private void parseSettingsFile(string settingsFilePath) // no hashtable, raise warning if (hashTableAsts.Count() == 0) { - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.InvalidProfile, settingsFilePath)); + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, EngineStrings.InvalidProfile, settingsFilePath)); } HashtableAst hashTableAst = hashTableAsts.First() as HashtableAst; @@ -479,7 +479,7 @@ private void parseSettingsFile(string settingsFilePath) } catch (InvalidOperationException e) { - throw new ArgumentException(Strings.InvalidProfile, e); + throw new ArgumentException(EngineStrings.InvalidProfile, e); } if (hashtable == null) @@ -487,7 +487,7 @@ private void parseSettingsFile(string settingsFilePath) throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, - Strings.InvalidProfile, + EngineStrings.InvalidProfile, settingsFilePath)); } @@ -641,7 +641,7 @@ private void ThrowInvalidDataException(IScriptExtent extent) { throw new InvalidDataException(string.Format( CultureInfo.CurrentCulture, - Strings.WrongValueFormat, + EngineStrings.WrongValueFormat, extent.StartLineNumber, extent.StartColumnNumber, extent.File ?? "")); diff --git a/Engine/Strings.Designer.cs b/Engine/Strings.Designer.cs deleted file mode 100644 index d7234f283..000000000 --- a/Engine/Strings.Designer.cs +++ /dev/null @@ -1,685 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Windows.PowerShell.ScriptAnalyzer.Strings", typeof(Strings).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Checking assembly file '{0}' .... - /// - internal static string CheckAssemblyFile { - get { - return ResourceManager.GetString("CheckAssemblyFile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checking module '{0}' .... - /// - internal static string CheckModuleName { - get { - return ResourceManager.GetString("CheckModuleName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to CommandInfo not found for function: {0}. - /// - internal static string CommandInfoNotFound { - get { - return ResourceManager.GetString("CommandInfoNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to "Argument should not be null.".. - /// - internal static string ConfigurableScriptRuleNRE { - get { - return ResourceManager.GetString("ConfigurableScriptRuleNRE", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to "Cannot find a ConfigurableRuleProperty attribute on property {0}".. - /// - internal static string ConfigurableScriptRulePropertyHasNotAttribute { - get { - return ResourceManager.GetString("ConfigurableScriptRulePropertyHasNotAttribute", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsFileHasInvalidHashtable. - /// - internal static string ConfigurationFileHasInvalidHashtable { - get { - return ResourceManager.GetString("ConfigurationFileHasInvalidHashtable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsFileHasNoHashTable. - /// - internal static string ConfigurationFileHasNoHashTable { - get { - return ResourceManager.GetString("ConfigurationFileHasNoHashTable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsFileNotFound. - /// - internal static string ConfigurationFileNotFound { - get { - return ResourceManager.GetString("ConfigurationFileNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsKeyNotAString. - /// - internal static string ConfigurationKeyNotAString { - get { - return ResourceManager.GetString("ConfigurationKeyNotAString", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsValueNotAString. - /// - internal static string ConfigurationValueNotAString { - get { - return ResourceManager.GetString("ConfigurationValueNotAString", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to SettingsValueWrongFormat. - /// - internal static string ConfigurationValueWrongFormat { - get { - return ResourceManager.GetString("ConfigurationValueWrongFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Writes all diagnostics to WriteObject.. - /// - internal static string DefaultLoggerDescription { - get { - return ResourceManager.GetString("DefaultLoggerDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to WriteObjects. - /// - internal static string DefaultLoggerName { - get { - return ResourceManager.GetString("DefaultLoggerName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Edge from {0} to {1} already exists.. - /// - internal static string DigraphEdgeAlreadyExists { - get { - return ResourceManager.GetString("DigraphEdgeAlreadyExists", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Vertex {0} already exists! Cannot add it to the digraph.. - /// - internal static string DigraphVertexAlreadyExists { - get { - return ResourceManager.GetString("DigraphVertexAlreadyExists", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Vertex {0} does not exist in the digraph.. - /// - internal static string DigraphVertexDoesNotExists { - get { - return ResourceManager.GetString("DigraphVertexDoesNotExists", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot determine line endings as the text probably contain mixed line endings.. - /// - internal static string EditableTextInvalidLineEnding { - get { - return ResourceManager.GetString("EditableTextInvalidLineEnding", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to TextEdit extent not completely contained in EditableText.. - /// - internal static string EditableTextRangeIsNotContained { - get { - return ResourceManager.GetString("EditableTextRangeIsNotContained", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find file '{0}'.. - /// - internal static string FileNotFound { - get { - return ResourceManager.GetString("FileNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find the path '{0}'.. - /// - internal static string InvalidPath { - get { - return ResourceManager.GetString("InvalidPath", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings file '{0}' is invalid because it does not contain a hashtable.. - /// - internal static string InvalidProfile { - get { - return ResourceManager.GetString("InvalidProfile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Key {0} in the settings is not a string.. - /// - internal static string KeyNotString { - get { - return ResourceManager.GetString("KeyNotString", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No loggers found.. - /// - internal static string LoggersNotFound { - get { - return ResourceManager.GetString("LoggersNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find rule extension '{0}'.. - /// - internal static string MissingRuleExtension { - get { - return ResourceManager.GetString("MissingRuleExtension", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Temporary module location: {0}.. - /// - internal static string ModuleDepHandlerTempLocation { - get { - return ResourceManager.GetString("ModuleDepHandlerTempLocation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} cannot be set by both positional and named arguments.. - /// - internal static string NamedAndPositionalArgumentsConflictError { - get { - return ResourceManager.GetString("NamedAndPositionalArgumentsConflictError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Named arguments must always come after positional arguments.. - /// - internal static string NamedArgumentsBeforePositionalError { - get { - return ResourceManager.GetString("NamedArgumentsBeforePositionalError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to RuleName must not be null.. - /// - internal static string NullRuleNameError { - get { - return ResourceManager.GetString("NullRuleNameError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parse error in script definition: {0} at line {1} column {2}.. - /// - internal static string ParseErrorFormatForScriptDefinition { - get { - return ResourceManager.GetString("ParseErrorFormatForScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parse error in file {0}: {1} at line {2} column {3}.. - /// - internal static string ParserErrorFormat { - get { - return ResourceManager.GetString("ParserErrorFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There are too many parser errors in {0}. Please correct them before running ScriptAnalyzer.. - /// - internal static string ParserErrorMessage { - get { - return ResourceManager.GetString("ParserErrorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There are too many parser errors in the script definition. Please correct them before running ScriptAnalyzer.. - /// - internal static string ParserErrorMessageForScriptDefinition { - get { - return ResourceManager.GetString("ParserErrorMessageForScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Column number cannot be less than 1.. - /// - internal static string PositionColumnLessThanOne { - get { - return ResourceManager.GetString("PositionColumnLessThanOne", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line number cannot be less than 1.. - /// - internal static string PositionLineLessThanOne { - get { - return ResourceManager.GetString("PositionLineLessThanOne", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Input position should be less than that of the invoking object.. - /// - internal static string PositionRefPosLessThanInputPos { - get { - return ResourceManager.GetString("PositionRefPosLessThanInputPos", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reference Position should begin before start Position of Range.. - /// - internal static string RangeRefPosShouldStartBeforeRangeStartPos { - get { - return ResourceManager.GetString("RangeRefPosShouldStartBeforeRangeStartPos", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Start position cannot be before End position.. - /// - internal static string RangeStartPosGreaterThanEndPos { - get { - return ResourceManager.GetString("RangeStartPosGreaterThanEndPos", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to RULE_ERROR. - /// - internal static string RuleErrorMessage { - get { - return ResourceManager.GetString("RuleErrorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find ScriptAnalyzer rules in the specified path. - /// - internal static string RulesNotFound { - get { - return ResourceManager.GetString("RulesNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Suppression Message Attribute error at line {0} in {1} : {2}. - /// - internal static string RuleSuppressionErrorFormat { - get { - return ResourceManager.GetString("RuleSuppressionErrorFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Suppression Message Attribute error at line {0} in script definition : {1}. - /// - internal static string RuleSuppressionErrorFormatScriptDefinition { - get { - return ResourceManager.GetString("RuleSuppressionErrorFormatScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find any DiagnosticRecord with the Rule Suppression ID {0}.. - /// - internal static string RuleSuppressionIDError { - get { - return ResourceManager.GetString("RuleSuppressionIDError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Rule {0} cannot be found.. - /// - internal static string RuleSuppressionRuleNameNotFound { - get { - return ResourceManager.GetString("RuleSuppressionRuleNameNotFound", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Found {0}. Will use it to provide settings for this invocation.. - /// - internal static string SettingsAutoDiscovered { - get { - return ResourceManager.GetString("SettingsAutoDiscovered", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot resolve settings file path '{0}'.. - /// - internal static string SettingsCannotFindFile { - get { - return ResourceManager.GetString("SettingsCannotFindFile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Dictionary should be indexable in a case-insensitive manner.. - /// - internal static string SettingsDictionaryShouldBeCaseInsesitive { - get { - return ResourceManager.GetString("SettingsDictionaryShouldBeCaseInsesitive", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Input should be a dictionary type.. - /// - internal static string SettingsInputShouldBeDictionary { - get { - return ResourceManager.GetString("SettingsInputShouldBeDictionary", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings should be either a file path, built-in preset or a hashtable.. - /// - internal static string SettingsInvalidType { - get { - return ResourceManager.GetString("SettingsInvalidType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot parse settings. Will abort the invocation.. - /// - internal static string SettingsNotParsable { - get { - return ResourceManager.GetString("SettingsNotParsable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings not provided. Will look for settings file in the given path {0}.. - /// - internal static string SettingsNotProvided { - get { - return ResourceManager.GetString("SettingsNotProvided", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Settings object could not be resolved.. - /// - internal static string SettingsObjectCouldNotBResolved { - get { - return ResourceManager.GetString("SettingsObjectCouldNotBResolved", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using settings file at {0}.. - /// - internal static string SettingsUsingFile { - get { - return ResourceManager.GetString("SettingsUsingFile", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using settings hashtable.. - /// - internal static string SettingsUsingHashtable { - get { - return ResourceManager.GetString("SettingsUsingHashtable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} property must be of type bool.. - /// - internal static string SettingsValueTypeMustBeBool { - get { - return ResourceManager.GetString("SettingsValueTypeMustBeBool", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to All the arguments of the Suppress Message Attribute should be string constants.. - /// - internal static string StringConstantArgumentsSuppressionAttributeError { - get { - return ResourceManager.GetString("StringConstantArgumentsSuppressionAttributeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find any Targets {0} that match the Scope {1} to apply the SuppressMessageAttribute.. - /// - internal static string TargetCannotBeFoundError { - get { - return ResourceManager.GetString("TargetCannotBeFoundError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If Target is specified, Scope must be specified.. - /// - internal static string TargetWithoutScopeSuppressionAttributeError { - get { - return ResourceManager.GetString("TargetWithoutScopeSuppressionAttributeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line element cannot be null.. - /// - internal static string TextEditNoNullItem { - get { - return ResourceManager.GetString("TextEditNoNullItem", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line element cannot be null.. - /// - internal static string TextLinesNoNullItem { - get { - return ResourceManager.GetString("TextLinesNoNullItem", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Analyzing file: {0}. - /// - internal static string VerboseFileMessage { - get { - return ResourceManager.GetString("VerboseFileMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Running {0} rule.. - /// - internal static string VerboseRunningMessage { - get { - return ResourceManager.GetString("VerboseRunningMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Analyzing Script Definition.. - /// - internal static string VerboseScriptDefinitionMessage { - get { - return ResourceManager.GetString("VerboseScriptDefinitionMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to WrongSettingsKey. - /// - internal static string WrongConfigurationKey { - get { - return ResourceManager.GetString("WrongConfigurationKey", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} is not a valid key in the settings hashtable: file {3}. Valid keys are ExcludeRules, IncludeRules and Severity.. - /// - internal static string WrongKey { - get { - return ResourceManager.GetString("WrongKey", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Key in the settings hashtable should be a string: line {0} column {1} in file {2}. - /// - internal static string WrongKeyFormat { - get { - return ResourceManager.GetString("WrongKeyFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} is not a valid key in the settings hashtable. Valid keys are ExcludeRules, IncludeRules and Severity.. - /// - internal static string WrongKeyHashTable { - get { - return ResourceManager.GetString("WrongKeyHashTable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Scope can only be either function or class.. - /// - internal static string WrongScopeArgumentSuppressionAttributeError { - get { - return ResourceManager.GetString("WrongScopeArgumentSuppressionAttributeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Value in the settings hashtable should be a string or an array of strings: line {0} column {1} in file {2}. - /// - internal static string WrongValueFormat { - get { - return ResourceManager.GetString("WrongValueFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Value {0} for key {1} has the wrong data type.. - /// - internal static string WrongValueHashTable { - get { - return ResourceManager.GetString("WrongValueHashTable", resourceCulture); - } - } - } -} diff --git a/Engine/TextEdit.cs b/Engine/TextEdit.cs index 1d013e9a5..e246dd825 100644 --- a/Engine/TextEdit.cs +++ b/Engine/TextEdit.cs @@ -89,7 +89,7 @@ public TextEdit( { throw new ArgumentException( String.Format(CultureInfo.CurrentCulture, - Strings.TextEditNoNullItem), nameof(lines)); + EngineStrings.TextEditNoNullItem), nameof(lines)); } Lines = lines.ToArray(); diff --git a/Engine/TextLines.cs b/Engine/TextLines.cs index 722501303..4d56eaff4 100644 --- a/Engine/TextLines.cs +++ b/Engine/TextLines.cs @@ -45,7 +45,7 @@ public TextLines(IEnumerable inputLines) : this() { throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, - Strings.TextLinesNoNullItem)); + EngineStrings.TextLinesNoNullItem)); } diff --git a/Engine/Strings.resx b/Engine/resources/EngineStrings.resx similarity index 100% rename from Engine/Strings.resx rename to Engine/resources/EngineStrings.resx diff --git a/New-StronglyTypedCsFileForResx.ps1 b/New-StronglyTypedCsFileForResx.ps1 deleted file mode 100644 index 1a2406dce..000000000 --- a/New-StronglyTypedCsFileForResx.ps1 +++ /dev/null @@ -1,148 +0,0 @@ -<# -# This script can be used to update the *.Designer file if a *.resx ressource file has been updated. -# However, it is recommended to use Visual Studio instead for editing ressources instead since it takes of that automatically and prodcues cleaner diffs. -#> -param( - [ValidateSet("Engine","Rules")] - [string] $project -) - -function Get-StronglyTypeCsFileForResx -{ - param($xml, $ModuleName, $ClassName) - - # Example - # - # $ClassName = Full.Name.Of.The.ClassFoo - # $shortClassName = ClassFoo - # $namespaceName = Full.Name.Of.The - - $shortClassName = $ClassName - $namespaceName = $null - - $lastIndexOfDot = $className.LastIndexOf(".") - if ($lastIndexOfDot -ne -1) - { - $namespaceName = $className.Substring(0, $lastIndexOfDot) - $shortClassName = $className.Substring($lastIndexOfDot + 1) - } - -$banner = @' -//------------------------------------------------------------------------------ -// -// This code was generated by a New-StronglyTypedCsFileForResx function. -// To add or remove a member, edit your .ResX file then rerun Start-ResGen. -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -{0} -'@ - -$namespace = @' -namespace {0} {{ -{1} -}} -'@ - -$body = @' -using System; -using System.Reflection; - -/// -/// A strongly-typed resource class, for looking up localized strings, etc. -/// -[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] -[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] -[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - -internal class {0} {{ - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal {0}() {{ - }} - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager {{ - get {{ - if (object.ReferenceEquals(resourceMan, null)) {{ - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("{3}", typeof({0}).GetTypeInfo().Assembly); - resourceMan = temp; - }} - return resourceMan; - }} - }} - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture {{ - get {{ - return resourceCulture; - }} - set {{ - resourceCulture = value; - }} - }} - {2} -}} -'@ - - $entry = @' - - /// - /// Looks up a localized string similar to {1} - /// - internal static string {0} {{ - get {{ - return ResourceManager.GetString("{0}", resourceCulture); - }} - }} -'@ - $entries = $xml.root.data | ForEach-Object { - if ($_) { - $val = $_.value.Replace("`n", "`n ///") - $name = $_.name.Replace(' ', '_') - $entry -f $name,$val - } - } | Out-String - - $bodyCode = $body -f $shortClassName,$ModuleName,$entries,$ClassName - - if ($NamespaceName) - { - $bodyCode = $namespace -f $NamespaceName, $bodyCode - } - - $resultCode = $banner -f $bodyCode - - return $resultCode -replace "`r`n?|`n","`r`n" -} - -$projectRoot = $PWD -if (-not (Test-Path "$projectRoot/global.json")) -{ - throw "Not in solution root: $projectRoot" -} -$inputFilePath = Join-Path $projectRoot "$project/Strings.resx" -$outputFilePath = Join-Path $projectRoot "$project/Strings.Designer.cs" -$className = "Microsoft.Windows.PowerShell.ScriptAnalyzer" -if ($project -eq "Rules") -{ - $className += ".BuiltinRules" -} -$className += ".Strings" -$xml = [xml](Get-Content -raw $inputFilePath) -$genSource = Get-StronglyTypeCsFileForResx -xml $xml -ModuleName Foo -ClassName $className -Set-Content -Encoding Ascii -Path $outputFilePath -Value $genSource diff --git a/README.md b/README.md index b72ea98df..a9a84d8e3 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,7 @@ Table of Contents - [Requirements](#requirements) * [Windows](#windows) * [Linux (*Tested only on Ubuntu 14.04*)](#linux-tested-only-on-ubuntu-1404) - + [From Source](#from-source) - - [Requirements](#requirements-1) - - [Steps](#steps) - - [Tests](#tests) +- [Building and Testing](#building-and-testing) - [Suppressing Rules](#suppressing-rules) - [Settings Support in ScriptAnalyzer](#settings-support-in-scriptanalyzer) * [Built-in Presets](#built-in-presets) @@ -29,7 +26,6 @@ Table of Contents - [Violation Correction](#violation-correction) - [Project Management Dashboard](#project-management-dashboard) - [Contributions are welcome](#contributions-are-welcome) -- [Creating a Release](#creating-a-release) - [Code of Conduct](#code-of-conduct) @@ -79,69 +75,9 @@ Exit ##### Linux (*Tested only on Ubuntu 14.04*) - PowerShell Core -### From Source - -* [.NET Core 2.1.4 SDK](https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.5-download.md) -* [PlatyPS 0.9.0 or greater](https://github.com/PowerShell/platyPS/releases) -* Optionally but recommended for development: [Visual Studio 2017](https://www.visualstudio.com/downloads/) - -#### Steps -* Obtain the source - - Download the latest source code from the [release page](https://github.com/PowerShell/PSScriptAnalyzer/releases) OR - - Clone the repository (needs git) - ```powershell - git clone https://github.com/PowerShell/PSScriptAnalyzer - ``` -* Navigate to the source directory - ```powershell - cd path/to/PSScriptAnalyzer - ``` -* Building - - You can either build using the `Visual Studio` solution `PSScriptAnalyzer.sln` or build using `PowerShell` specifically for your platform as follows: - * Windows PowerShell version 5.0 and greater - ```powershell - .\buildCoreClr.ps1 -Framework net451 -Configuration Release -Build - ``` - * Windows PowerShell version 3.0 and 4.0 - ```powershell - .\buildCoreClr.ps1 -Framework net451 -Configuration PSV3Release -Build - ``` - * PowerShell Core - ```powershell - .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build - ``` -* Build documenatation - ```powershell - .\build.ps1 -BuildDocs - ``` -* Import the module -```powershell -Import-Module .\out\PSScriptAnalyzer\PSScriptAnalyzer.psd1 -``` - -To confirm installation: run `Get-ScriptAnalyzerRule` in the PowerShell console to obtain the built-in rules - -* Adding/Removing resource strings - -For adding/removing resource strings in the `*.resx` files, it is recommended to use `Visual Studio` since it automatically updates the strongly typed `*.Designer.cs` files. The `Visual Studio 2017 Community Edition` is free to use but should you not have/want to use `Visual Studio` then you can either manually adapt the `*.Designer.cs` files or use the `New-StronglyTypedCsFileForResx.ps1` script although the latter is discouraged since it leads to a bad diff of the `*.Designer.cs` files. +#### Building And Testing -#### Tests -Pester-based ScriptAnalyzer Tests are located in `path/to/PSScriptAnalyzer/Tests` folder. - -* Ensure [Pester 4.3.1](https://www.powershellgallery.com/packages/Pester/4.3.1) is installed -* Copy `path/to/PSScriptAnalyzer/out/PSScriptAnalyzer` to a folder in `PSModulePath` -* Go the Tests folder in your local repository -* Run Engine Tests: -``` PowerShell -cd /path/to/PSScriptAnalyzer/Tests/Engine -Invoke-Pester -``` -* Run Tests for Built-in rules: -``` PowerShell -cd /path/to/PSScriptAnalyzer/Tests/Rules -Invoke-Pester -``` +see [Building and Testing ScriptAnalyzer](docs/dev-process/building.md) for more information [Back to ToC](#table-of-contents) @@ -333,8 +269,8 @@ The initial motivation behind having the `SuggestedCorrections` property on the [Back to ToC](#table-of-contents) -Project Management Dashboard -============================ +# Project Management Dashboard + You can track issues, pull requests, backlog items here: [![Stories in progress](https://badge.waffle.io/PowerShell/PSScriptAnalyzer.png?label=In%20Progress&title=In%20Progress)](https://waffle.io/PowerShell/PSScriptAnalyzer) @@ -361,26 +297,6 @@ There are many ways to contribute: [Back to ToC](#table-of-contents) -Creating a Release -================ - -- Update changelog (`changelog.md`) with the new version number and change set. When updating the changelog please follow the same pattern as that of previous change sets (otherwise this may break the next step). -- Import the ReleaseMaker module and execute `New-Release` cmdlet to perform the following actions. - - Update module manifest (engine/PSScriptAnalyzer.psd1) with the new version number and change set - - Update the version number in `Engine/Engine.csproj` and `Rules/Rules.csproj` - - Create a release build in `out/` - -```powershell - PS> Import-Module .\Utils\ReleaseMaker.psm1 - PS> New-Release -``` - -- Sign the binaries and PowerShell files in the release build and publish the module to [PowerShell Gallery](www.powershellgallery.com). -- Create a PR on `development` branch, with all the changes made in the previous step. -- Merge the changes to `development` and then merge `development` to `master` (Note that the `development` to `master` merge should be a `fast-forward` merge). -- Draft a new release on github and tag `master` with the new version number. - -[Back to ToC](#table-of-contents) Code of Conduct =============== diff --git a/ResGen/Program.cs b/ResGen/Program.cs new file mode 100644 index 000000000..53eab82b8 --- /dev/null +++ b/ResGen/Program.cs @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml.Linq; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + IEnumerable dirs; + string fileFilter; + + if (args.Length == 1) + { + // We are assuming resgen is run with 'dotnet run pathToResxFile.resx'. + fileFilter = Path.GetFileName(args[0]); + string moduleDirectory = Path.GetDirectoryName(Path.GetDirectoryName(args[0])); + dirs = new List() { moduleDirectory }; + } + else + { + // We are assuming resgen is run with 'dotnet run' + // so we can use relative path to get a parent directory + // to process all *.resx files in all project subdirectories. + fileFilter = "*.resx"; + dirs = Directory.EnumerateDirectories(".."); + } + + foreach (string folder in dirs) + { + string moduleName = "Microsoft.Windows.PowerShell.ScriptAnalyzer"; // Path.GetFileName(folder); + string resourcePath = Path.Combine(folder, "resources"); + + if (Directory.Exists(resourcePath)) + { + string genFolder = Path.Combine(folder, "gen"); + if (!Directory.Exists(genFolder)) + { + Directory.CreateDirectory(genFolder); + } + + foreach (string resxPath in Directory.EnumerateFiles(resourcePath, fileFilter)) + { + string className = Path.GetFileNameWithoutExtension(resxPath); + string sourceCode = GetStronglyTypeCsFileForResx(resxPath, moduleName, className); + string outPath = Path.Combine(genFolder, className + ".cs"); + Console.WriteLine("ResGen for " + outPath); + File.WriteAllText(outPath, sourceCode); + } + } + } + } + + private static string GetStronglyTypeCsFileForResx(string xmlPath, string moduleName, string className) + { + // Example + // + // className = Full.Name.Of.The.ClassFoo + // shortClassName = ClassFoo + // namespaceName = Full.Name.Of.The + + string shortClassName = className; + string namespaceName = null; + int lastIndexOfDot = className.LastIndexOf('.'); + if (lastIndexOfDot != -1) + { + namespaceName = className.Substring(0, lastIndexOfDot); + shortClassName = className.Substring(lastIndexOfDot + 1); + } + + var entries = new StringBuilder(); + XElement root = XElement.Parse(File.ReadAllText(xmlPath)); + foreach (var data in root.Elements("data")) + { + string value = data.Value.Replace("\n", "\n ///"); + string name = data.Attribute("name").Value.Replace(' ', '_'); + entries.AppendFormat(ENTRY, name, value); + } + + string bodyCode = string.Format(BODY, shortClassName, moduleName, entries.ToString(), className); + if (namespaceName != null) + { + bodyCode = string.Format(NAMESPACE, namespaceName, bodyCode); + } + + string resultCode = string.Format(BANNER, bodyCode).Replace("\r\n?|\n", "\r\n"); + return resultCode; + } + + private static readonly string BANNER = @" +//------------------------------------------------------------------------------ +// +// This code was generated by a dotnet run from src\ResGen folder. +// To add or remove a member, edit your .resx file then rerun src\ResGen. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +{0} +"; + + private static readonly string NAMESPACE = @" +namespace {0} {{ +{1} +}} +"; + private static readonly string BODY = @" +using System; +using System.Reflection; + +/// +/// A strongly-typed resource class, for looking up localized strings, etc. +/// +[global::System.CodeDom.Compiler.GeneratedCodeAttribute(""System.Resources.Tools.StronglyTypedResourceBuilder"", ""4.0.0.0"")] +[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] +[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + +internal class {0} {{ + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(""Microsoft.Performance"", ""CA1811:AvoidUncalledPrivateCode"")] + internal {0}() {{ + }} + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager {{ + get {{ + if (object.ReferenceEquals(resourceMan, null)) {{ + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(""{1}.resources.{3}"", typeof({0}).GetTypeInfo().Assembly); + resourceMan = temp; + }} + return resourceMan; + }} + }} + + /// + /// Overrides the current threads CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture {{ + get {{ + return resourceCulture; + }} + set {{ + resourceCulture = value; + }} + }} + {2} +}} +"; + + private static readonly string ENTRY = @" + + /// + /// Looks up a localized string similar to {1} + /// + internal static string {0} {{ + get {{ + return ResourceManager.GetString(""{0}"", resourceCulture); + }} + }} +"; + + } +} diff --git a/ResGen/ResGen.csproj b/ResGen/ResGen.csproj new file mode 100644 index 000000000..87315226e --- /dev/null +++ b/ResGen/ResGen.csproj @@ -0,0 +1,11 @@ + + + + Generates C# typed bindings for .resx files + netcoreapp2.0 + resgen + Exe + win7-x86;win7-x64;osx.10.12-x64;linux-x64 + + + diff --git a/Rules/Strings.Designer.cs b/Rules/Strings.Designer.cs deleted file mode 100644 index 565e67629..000000000 --- a/Rules/Strings.Designer.cs +++ /dev/null @@ -1,2728 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Strings { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Strings() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Windows.PowerShell.ScriptAnalyzer.Strings", typeof(Strings).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Align assignment statement. - /// - internal static string AlignAssignmentStatementCommonName { - get { - return ResourceManager.GetString("AlignAssignmentStatementCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line up assignment statements such that the assignment operator are aligned.. - /// - internal static string AlignAssignmentStatementDescription { - get { - return ResourceManager.GetString("AlignAssignmentStatementDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Assignment statements are not aligned. - /// - internal static string AlignAssignmentStatementError { - get { - return ResourceManager.GetString("AlignAssignmentStatementError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AlignAssignmentStatement. - /// - internal static string AlignAssignmentStatementName { - get { - return ResourceManager.GetString("AlignAssignmentStatementName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidAssignmentToAutomaticVariable. - /// - internal static string AvoidAssignmentToAutomaticVariableName { - get { - return ResourceManager.GetString("AvoidAssignmentToAutomaticVariableName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use a different variable name. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariable { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariable", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Changing automtic variables might have undesired side effects. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariableCommonName { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariableCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to This automatic variables is built into PowerShell and readonly.. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariableDescription { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariableDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Variable '{0}' cannot be assigned since it is a readonly automatic variable that is built into PowerShell, please use a different name.. - /// - internal static string AvoidAssignmentToReadOnlyAutomaticVariableError { - get { - return ResourceManager.GetString("AvoidAssignmentToReadOnlyAutomaticVariableError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using ComputerName Hardcoded. - /// - internal static string AvoidComputerNameHardcodedCommonName { - get { - return ResourceManager.GetString("AvoidComputerNameHardcodedCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The ComputerName parameter of a cmdlet should not be hardcoded as this will expose sensitive information about the system.. - /// - internal static string AvoidComputerNameHardcodedDescription { - get { - return ResourceManager.GetString("AvoidComputerNameHardcodedDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The ComputerName parameter of cmdlet '{0}' is hardcoded. This will expose sensitive information about the system if the script is shared.. - /// - internal static string AvoidComputerNameHardcodedError { - get { - return ResourceManager.GetString("AvoidComputerNameHardcodedError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingComputerNameHardcoded. - /// - internal static string AvoidComputerNameHardcodedName { - get { - return ResourceManager.GetString("AvoidComputerNameHardcodedName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Default Value For Mandatory Parameter. - /// - internal static string AvoidDefaultValueForMandatoryParameterCommonName { - get { - return ResourceManager.GetString("AvoidDefaultValueForMandatoryParameterCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Mandatory parameter should not be initialized with a default value in the param block because this value will be ignored.. To fix a violation of this rule, please avoid initializing a value for the mandatory parameter in the param block.. - /// - internal static string AvoidDefaultValueForMandatoryParameterDescription { - get { - return ResourceManager.GetString("AvoidDefaultValueForMandatoryParameterDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Mandatory Parameter '{0}' is initialized in the Param block. To fix a violation of this rule, please leave it unintialized.. - /// - internal static string AvoidDefaultValueForMandatoryParameterError { - get { - return ResourceManager.GetString("AvoidDefaultValueForMandatoryParameterError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidDefaultValueForMandatoryParameter. - /// - internal static string AvoidDefaultValueForMandatoryParameterName { - get { - return ResourceManager.GetString("AvoidDefaultValueForMandatoryParameterName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Switch Parameters Should Not Default To True. - /// - internal static string AvoidDefaultValueSwitchParameterCommonName { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Switch parameter should not default to true.. - /// - internal static string AvoidDefaultValueSwitchParameterDescription { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' has a switch parameter default to true.. - /// - internal static string AvoidDefaultValueSwitchParameterError { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Script definition has a switch parameter default to true.. - /// - internal static string AvoidDefaultValueSwitchParameterErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidDefaultValueSwitchParameter. - /// - internal static string AvoidDefaultValueSwitchParameterName { - get { - return ResourceManager.GetString("AvoidDefaultValueSwitchParameterName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Empty catch block is used. Please use Write-Error or throw statements in catch blocks.. - /// - internal static string AvoidEmptyCatchBlockError { - get { - return ResourceManager.GetString("AvoidEmptyCatchBlockError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid global aliases.. - /// - internal static string AvoidGlobalAliasesCommonName { - get { - return ResourceManager.GetString("AvoidGlobalAliasesCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that global aliases are not used. Global aliases are strongly discouraged as they overwrite desired aliases with name conflicts.. - /// - internal static string AvoidGlobalAliasesDescription { - get { - return ResourceManager.GetString("AvoidGlobalAliasesDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid creating aliases with a Global scope.. - /// - internal static string AvoidGlobalAliasesError { - get { - return ResourceManager.GetString("AvoidGlobalAliasesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidGlobalAliases. - /// - internal static string AvoidGlobalAliasesName { - get { - return ResourceManager.GetString("AvoidGlobalAliasesName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid global functiosn and aliases. - /// - internal static string AvoidGlobalFunctionsCommonName { - get { - return ResourceManager.GetString("AvoidGlobalFunctionsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that global functions and aliases are not used. Global functions are strongly discouraged as they can cause errors across different systems.. - /// - internal static string AvoidGlobalFunctionsDescription { - get { - return ResourceManager.GetString("AvoidGlobalFunctionsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid creating functions with a Global scope.. - /// - internal static string AvoidGlobalFunctionsError { - get { - return ResourceManager.GetString("AvoidGlobalFunctionsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidGlobalFunctions. - /// - internal static string AvoidGlobalFunctionsName { - get { - return ResourceManager.GetString("AvoidGlobalFunctionsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No Global Variables. - /// - internal static string AvoidGlobalVarsCommonName { - get { - return ResourceManager.GetString("AvoidGlobalVarsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that global variables are not used. Global variables are strongly discouraged as they can cause errors across different systems.. - /// - internal static string AvoidGlobalVarsDescription { - get { - return ResourceManager.GetString("AvoidGlobalVarsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Found global variable '{0}'.. - /// - internal static string AvoidGlobalVarsError { - get { - return ResourceManager.GetString("AvoidGlobalVarsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidGlobalVars. - /// - internal static string AvoidGlobalVarsName { - get { - return ResourceManager.GetString("AvoidGlobalVarsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Invoking Empty Members. - /// - internal static string AvoidInvokingEmptyMembersCommonName { - get { - return ResourceManager.GetString("AvoidInvokingEmptyMembersCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invoking non-constant members would cause potential bugs. Please double check the syntax to make sure members invoked are non-constant.. - /// - internal static string AvoidInvokingEmptyMembersDescription { - get { - return ResourceManager.GetString("AvoidInvokingEmptyMembersDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' has non-constant members. Invoking non-constant members may cause bugs in the script.. - /// - internal static string AvoidInvokingEmptyMembersError { - get { - return ResourceManager.GetString("AvoidInvokingEmptyMembersError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidInvokingEmptyMembers. - /// - internal static string AvoidInvokingEmptyMembersName { - get { - return ResourceManager.GetString("AvoidInvokingEmptyMembersName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid using null or empty HelpMessage parameter attribute.. - /// - internal static string AvoidNullOrEmptyHelpMessageAttributeCommonName { - get { - return ResourceManager.GetString("AvoidNullOrEmptyHelpMessageAttributeCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Setting the HelpMessage attribute to an empty string or null value causes PowerShell interpreter to throw an error while executing the corresponding function.. - /// - internal static string AvoidNullOrEmptyHelpMessageAttributeDescription { - get { - return ResourceManager.GetString("AvoidNullOrEmptyHelpMessageAttributeDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to HelpMessage parameter attribute should not be null or empty. To fix a violation of this rule, please set its value to a non-empty string.. - /// - internal static string AvoidNullOrEmptyHelpMessageAttributeError { - get { - return ResourceManager.GetString("AvoidNullOrEmptyHelpMessageAttributeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidNullOrEmptyHelpMessageAttribute. - /// - internal static string AvoidNullOrEmptyHelpMessageAttributeName { - get { - return ResourceManager.GetString("AvoidNullOrEmptyHelpMessageAttributeName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using ShouldContinue Without Boolean Force Parameter. - /// - internal static string AvoidShouldContinueWithoutForceCommonName { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Functions that use ShouldContinue should have a boolean force parameter to allow user to bypass it.. - /// - internal static string AvoidShouldContinueWithoutForceDescription { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function '{0}' in file '{1}' uses ShouldContinue but does not have a boolean force parameter. The force parameter will allow users of the script to bypass ShouldContinue prompt. - /// - internal static string AvoidShouldContinueWithoutForceError { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function '{0}' in script definition uses ShouldContinue but does not have a boolean force parameter. The force parameter will allow users of the script to bypass ShouldContinue prompt. - /// - internal static string AvoidShouldContinueWithoutForceErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidShouldContinueWithoutForce. - /// - internal static string AvoidShouldContinueWithoutForceName { - get { - return ResourceManager.GetString("AvoidShouldContinueWithoutForceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid trailing whitespace. - /// - internal static string AvoidTrailingWhitespaceCommonName { - get { - return ResourceManager.GetString("AvoidTrailingWhitespaceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each line should have no trailing whitespace.. - /// - internal static string AvoidTrailingWhitespaceDescription { - get { - return ResourceManager.GetString("AvoidTrailingWhitespaceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Line has trailing whitespace. - /// - internal static string AvoidTrailingWhitespaceError { - get { - return ResourceManager.GetString("AvoidTrailingWhitespaceError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidTrailingWhitespace. - /// - internal static string AvoidTrailingWhitespaceName { - get { - return ResourceManager.GetString("AvoidTrailingWhitespaceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No traps in the script.. - /// - internal static string AvoidTrapStatementCommonName { - get { - return ResourceManager.GetString("AvoidTrapStatementCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid using Traps in the script.. - /// - internal static string AvoidTrapStatementDescription { - get { - return ResourceManager.GetString("AvoidTrapStatementDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Trap found.. - /// - internal static string AvoidTrapStatementError { - get { - return ResourceManager.GetString("AvoidTrapStatementError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidTrapStatement. - /// - internal static string AvoidTrapStatementName { - get { - return ResourceManager.GetString("AvoidTrapStatementName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Initializing non-global variables. - /// - internal static string AvoidUninitializedVariableCommonName { - get { - return ResourceManager.GetString("AvoidUninitializedVariableCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Non-global variables must be initialized. To fix a violation of this rule, please initialize non-global variables.. - /// - internal static string AvoidUninitializedVariableDescription { - get { - return ResourceManager.GetString("AvoidUninitializedVariableDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Variable '{0}' is not initialized. Non-global variables must be initialized. To fix a violation of this rule, please initialize non-global variables.. - /// - internal static string AvoidUninitializedVariableError { - get { - return ResourceManager.GetString("AvoidUninitializedVariableError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUninitializedVariable. - /// - internal static string AvoidUninitializedVariableName { - get { - return ResourceManager.GetString("AvoidUninitializedVariableName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Module Must Be Loadable. - /// - internal static string AvoidUnloadableModuleCommonName { - get { - return ResourceManager.GetString("AvoidUnloadableModuleCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If a script file is in a PowerShell module folder, then that folder must be loadable.. - /// - internal static string AvoidUnloadableModuleDescription { - get { - return ResourceManager.GetString("AvoidUnloadableModuleDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot load the module '{0}' that file '{1}' is in.. - /// - internal static string AvoidUnloadableModuleError { - get { - return ResourceManager.GetString("AvoidUnloadableModuleError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUnloadableModule. - /// - internal static string AvoidUnloadableModuleName { - get { - return ResourceManager.GetString("AvoidUnloadableModuleName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Username and Password Parameters. - /// - internal static string AvoidUsernameAndPasswordParamsCommonName { - get { - return ResourceManager.GetString("AvoidUsernameAndPasswordParamsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Functions should take in a Credential parameter of type PSCredential (with a Credential transformation attribute defined after it in PowerShell 4.0 or earlier) or set the Password parameter to type SecureString.. - /// - internal static string AvoidUsernameAndPasswordParamsDescription { - get { - return ResourceManager.GetString("AvoidUsernameAndPasswordParamsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function '{0}' has both Username and Password parameters. Either set the type of the Password parameter to SecureString or replace the Username and Password parameters with a Credential parameter of type PSCredential. If using a Credential parameter in PowerShell 4.0 or earlier, please define a credential transformation attribute after the PSCredential type attribute.. - /// - internal static string AvoidUsernameAndPasswordParamsError { - get { - return ResourceManager.GetString("AvoidUsernameAndPasswordParamsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingUserNameAndPassWordParams. - /// - internal static string AvoidUsernameAndPasswordParamsName { - get { - return ResourceManager.GetString("AvoidUsernameAndPasswordParamsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Clear-Host. - /// - internal static string AvoidUsingClearHostCommonName { - get { - return ResourceManager.GetString("AvoidUsingClearHostCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using Clear-Host is not recommended because the cmdlet may not work in some hosts or there may even be no hosts at all.. - /// - internal static string AvoidUsingClearHostDescription { - get { - return ResourceManager.GetString("AvoidUsingClearHostDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses Clear-Host. This is not recommended because it may not work in some hosts or there may even be no hosts at all.. - /// - internal static string AvoidUsingClearHostError { - get { - return ResourceManager.GetString("AvoidUsingClearHostError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingClearHost. - /// - internal static string AvoidUsingClearHostName { - get { - return ResourceManager.GetString("AvoidUsingClearHostName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Cmdlet Aliases. - /// - internal static string AvoidUsingCmdletAliasesCommonName { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace {0} with {1}. - /// - internal static string AvoidUsingCmdletAliasesCorrectionDescription { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. But when writing scripts that will potentially need to be maintained over time, either by the original author or another Windows PowerShell scripter, please consider using full cmdlet name instead of alias. Aliases can introduce these problems, readability, understandability and availability.. - /// - internal static string AvoidUsingCmdletAliasesDescription { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' is an alias of '{1}'. Alias can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.. - /// - internal static string AvoidUsingCmdletAliasesError { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingCmdletAliases. - /// - internal static string AvoidUsingCmdletAliasesName { - get { - return ResourceManager.GetString("AvoidUsingCmdletAliasesName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses Console.'{1}'. Using Console to write is not recommended because it may not work in all hosts or there may even be no hosts at all. Use Write-Output instead.. - /// - internal static string AvoidUsingConsoleWriteError { - get { - return ResourceManager.GetString("AvoidUsingConsoleWriteError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using SecureString With Plain Text. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextCommonName { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using ConvertTo-SecureString with plain text will expose secure information.. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextDescription { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses ConvertTo-SecureString with plaintext. This will expose secure information. Encrypted standard strings should be used instead.. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextError { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Script definition uses ConvertTo-SecureString with plaintext. This will expose secure information. Encrypted standard strings should be used instead.. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingConvertToSecureStringWithPlainText. - /// - internal static string AvoidUsingConvertToSecureStringWithPlainTextName { - get { - return ResourceManager.GetString("AvoidUsingConvertToSecureStringWithPlainTextName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Deprecated Manifest Fields. - /// - internal static string AvoidUsingDeprecatedManifestFieldsCommonName { - get { - return ResourceManager.GetString("AvoidUsingDeprecatedManifestFieldsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to "ModuleToProcess" is obsolete in the latest PowerShell version. Please update with the latest field "RootModule" in manifest files to avoid PowerShell version inconsistency.. - /// - internal static string AvoidUsingDeprecatedManifestFieldsDescription { - get { - return ResourceManager.GetString("AvoidUsingDeprecatedManifestFieldsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingDeprecatedManifestFields. - /// - internal static string AvoidUsingDeprecatedManifestFieldsName { - get { - return ResourceManager.GetString("AvoidUsingDeprecatedManifestFieldsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Empty Catch Block. - /// - internal static string AvoidUsingEmptyCatchBlockCommonName { - get { - return ResourceManager.GetString("AvoidUsingEmptyCatchBlockCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Empty catch blocks are considered poor design decisions because if an error occurs in the try block, this error is simply swallowed and not acted upon. While this does not inherently lead to bad things. It can and this should be avoided if possible. To fix a violation of this rule, using Write-Error or throw statements in catch blocks.. - /// - internal static string AvoidUsingEmptyCatchBlockDescription { - get { - return ResourceManager.GetString("AvoidUsingEmptyCatchBlockDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingEmptyCatchBlock. - /// - internal static string AvoidUsingEmptyCatchBlockName { - get { - return ResourceManager.GetString("AvoidUsingEmptyCatchBlockName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using File Path. - /// - internal static string AvoidUsingFilePathCommonName { - get { - return ResourceManager.GetString("AvoidUsingFilePathCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to If a rooted file path is used in a script that is published online, this may expose information about your computer. Furthermore, the file path may not work on other computer when they try to use the script.. - /// - internal static string AvoidUsingFilePathDescription { - get { - return ResourceManager.GetString("AvoidUsingFilePathDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file path '{0}' of '{1}' is rooted. This should be avoided if '{1}' is published online.. - /// - internal static string AvoidUsingFilePathError { - get { - return ResourceManager.GetString("AvoidUsingFilePathError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingFilePath. - /// - internal static string AvoidUsingFilePathName { - get { - return ResourceManager.GetString("AvoidUsingFilePathName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Internal URLs. - /// - internal static string AvoidUsingInternalURLsCommonName { - get { - return ResourceManager.GetString("AvoidUsingInternalURLsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using Internal URLs in the scripts may cause security problems.. - /// - internal static string AvoidUsingInternalURLsDescription { - get { - return ResourceManager.GetString("AvoidUsingInternalURLsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' could be an internal URL. Using internal URL directly in the script may cause potential information disclosure.. - /// - internal static string AvoidUsingInternalURLsError { - get { - return ResourceManager.GetString("AvoidUsingInternalURLsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingInternalURLs. - /// - internal static string AvoidUsingInternalURLsName { - get { - return ResourceManager.GetString("AvoidUsingInternalURLsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invoke-Expression is used. Please remove Invoke-Expression from script and find other options instead.. - /// - internal static string AvoidUsingInvokeExpressionError { - get { - return ResourceManager.GetString("AvoidUsingInvokeExpressionError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Invoke-Expression. - /// - internal static string AvoidUsingInvokeExpressionRuleCommonName { - get { - return ResourceManager.GetString("AvoidUsingInvokeExpressionRuleCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Invoke-Expression cmdlet evaluates or runs a specified string as a command and returns the results of the expression or command. It can be extraordinarily powerful so it is not that you want to never use it but you need to be very careful about using it. In particular, you are probably on safe ground if the data only comes from the program itself. If you include any data provided from the user - you need to protect yourself from Code Injection. To fix a violation of this rule, please remove Invoke-Exp [rest of string was truncated]";. - /// - internal static string AvoidUsingInvokeExpressionRuleDescription { - get { - return ResourceManager.GetString("AvoidUsingInvokeExpressionRuleDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingInvokeExpression. - /// - internal static string AvoidUsingInvokeExpressionRuleName { - get { - return ResourceManager.GetString("AvoidUsingInvokeExpressionRuleName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Plain Text For Password Parameter. - /// - internal static string AvoidUsingPlainTextForPasswordCommonName { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set {0} type to SecureString. - /// - internal static string AvoidUsingPlainTextForPasswordCorrectionDescription { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Password parameters that take in plaintext will expose passwords and compromise the security of your system.. - /// - internal static string AvoidUsingPlainTextForPasswordDescription { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' should use SecureString, otherwise this will expose sensitive information. See ConvertTo-SecureString for more information.. - /// - internal static string AvoidUsingPlainTextForPasswordError { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingPlainTextForPassword. - /// - internal static string AvoidUsingPlainTextForPasswordName { - get { - return ResourceManager.GetString("AvoidUsingPlainTextForPasswordName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Positional Parameters. - /// - internal static string AvoidUsingPositionalParametersCommonName { - get { - return ResourceManager.GetString("AvoidUsingPositionalParametersCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Readability and clarity should be the goal of any script we expect to maintain over time. When calling a command that takes parameters, where possible consider using name parameters as opposed to positional parameters. To fix a violation of this rule, please use named parameters instead of positional parameters when calling a command.. - /// - internal static string AvoidUsingPositionalParametersDescription { - get { - return ResourceManager.GetString("AvoidUsingPositionalParametersDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet '{0}' has positional parameter. Please use named parameters instead of positional parameters when calling a command.. - /// - internal static string AvoidUsingPositionalParametersError { - get { - return ResourceManager.GetString("AvoidUsingPositionalParametersError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingPositionalParameters. - /// - internal static string AvoidUsingPositionalParametersName { - get { - return ResourceManager.GetString("AvoidUsingPositionalParametersName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Get-WMIObject, Remove-WMIObject, Invoke-WmiMethod, Register-WmiEvent, Set-WmiInstance. - /// - internal static string AvoidUsingWMICmdletCommonName { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Deprecated. Starting in Windows PowerShell 3.0, these cmdlets have been superseded by CIM cmdlets.. - /// - internal static string AvoidUsingWMICmdletDescription { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses WMI cmdlet. For PowerShell 3.0 and above, use CIM cmdlet which perform the same tasks as the WMI cmdlets. The CIM cmdlets comply with WS-Management (WSMan) standards and with the Common Information Model (CIM) standard, which enables the cmdlets to use the same techniques to manage Windows computers and those running other operating systems.. - /// - internal static string AvoidUsingWMICmdletError { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Script definition uses WMI cmdlet. For PowerShell 3.0 and above, use CIM cmdlet which perform the same tasks as the WMI cmdlets. The CIM cmdlets comply with WS-Management (WSMan) standards and with the Common Information Model (CIM) standard, which enables the cmdlets to use the same techniques to manage Windows computers and those running other operating systems.. - /// - internal static string AvoidUsingWMICmdletErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingWMICmdlet. - /// - internal static string AvoidUsingWMICmdletName { - get { - return ResourceManager.GetString("AvoidUsingWMICmdletName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid Using Write-Host. - /// - internal static string AvoidUsingWriteHostCommonName { - get { - return ResourceManager.GetString("AvoidUsingWriteHostCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Avoid using the Write-Host cmdlet. Instead, use Write-Output, Write-Verbose, or Write-Information. Because Write-Host is host-specific, its implementation might vary unpredictably. Also, prior to PowerShell 5.0, Write-Host did not write to a stream, so users cannot suppress it, capture its value, or redirect it.. - /// - internal static string AvoidUsingWriteHostDescription { - get { - return ResourceManager.GetString("AvoidUsingWriteHostDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File '{0}' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.. - /// - internal static string AvoidUsingWriteHostError { - get { - return ResourceManager.GetString("AvoidUsingWriteHostError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Script definition uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.. - /// - internal static string AvoidUsingWriteHostErrorScriptDefinition { - get { - return ResourceManager.GetString("AvoidUsingWriteHostErrorScriptDefinition", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to AvoidUsingWriteHost. - /// - internal static string AvoidUsingWriteHostName { - get { - return ResourceManager.GetString("AvoidUsingWriteHostName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Command Not Found. - /// - internal static string CommandNotFoundCommonName { - get { - return ResourceManager.GetString("CommandNotFoundCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Commands that are undefined or do not exist should not be used.. - /// - internal static string CommandNotFoundDescription { - get { - return ResourceManager.GetString("CommandNotFoundDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Command '{0}' Is Not Found. - /// - internal static string CommandNotFoundError { - get { - return ResourceManager.GetString("CommandNotFoundError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to CommandNotFound. - /// - internal static string CommandNotFoundName { - get { - return ResourceManager.GetString("CommandNotFoundName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DscExamplesPresent. - /// - internal static string DscExamplesPresent { - get { - return ResourceManager.GetString("DscExamplesPresent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DSC examples are present. - /// - internal static string DscExamplesPresentCommonName { - get { - return ResourceManager.GetString("DscExamplesPresentCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Every DSC resource module should contain folder "Examples" with sample configurations for every resource. Sample configurations should have resource name they are demonstrating in the title.. - /// - internal static string DscExamplesPresentDescription { - get { - return ResourceManager.GetString("DscExamplesPresentDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No examples found for resource '{0}'. - /// - internal static string DscExamplesPresentNoExamplesError { - get { - return ResourceManager.GetString("DscExamplesPresentNoExamplesError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PSDSC. - /// - internal static string DSCSourceName { - get { - return ResourceManager.GetString("DSCSourceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DscTestsPresent. - /// - internal static string DscTestsPresent { - get { - return ResourceManager.GetString("DscTestsPresent", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Dsc tests are present. - /// - internal static string DscTestsPresentCommonName { - get { - return ResourceManager.GetString("DscTestsPresentCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Every DSC resource module should contain folder "Tests" with tests for every resource. Test scripts should have resource name they are testing in the file name.. - /// - internal static string DscTestsPresentDescription { - get { - return ResourceManager.GetString("DscTestsPresentDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to No tests found for resource '{0}'. - /// - internal static string DscTestsPresentNoTestsError { - get { - return ResourceManager.GetString("DscTestsPresentNoTestsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Misleading Backtick. - /// - internal static string MisleadingBacktickCommonName { - get { - return ResourceManager.GetString("MisleadingBacktickCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ending a line with an escaped whitepsace character is misleading. A trailing backtick is usually used for line continuation. Users typically don't intend to end a line with escaped whitespace.. - /// - internal static string MisleadingBacktickDescription { - get { - return ResourceManager.GetString("MisleadingBacktickDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to This line has a backtick at the end trailed by a whitespace character. Did you mean for this to be a line continuation?. - /// - internal static string MisleadingBacktickError { - get { - return ResourceManager.GetString("MisleadingBacktickError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to MisleadingBacktick. - /// - internal static string MisleadingBacktickName { - get { - return ResourceManager.GetString("MisleadingBacktickName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Module Manifest Fields. - /// - internal static string MissingModuleManifestFieldCommonName { - get { - return ResourceManager.GetString("MissingModuleManifestFieldCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add {0} = {1} to the module manifest. - /// - internal static string MissingModuleManifestFieldCorrectionDescription { - get { - return ResourceManager.GetString("MissingModuleManifestFieldCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Some fields of the module manifest (such as ModuleVersion) are required.. - /// - internal static string MissingModuleManifestFieldDescription { - get { - return ResourceManager.GetString("MissingModuleManifestFieldDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to MissingModuleManifestField. - /// - internal static string MissingModuleManifestFieldName { - get { - return ResourceManager.GetString("MissingModuleManifestFieldName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}{1}. - /// - internal static string NameSpaceFormat { - get { - return ResourceManager.GetString("NameSpaceFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Not all code path in {0} function in DSC Class {1} returns a value. - /// - internal static string NotAllCodePathReturnsDSCFunctionsError { - get { - return ResourceManager.GetString("NotAllCodePathReturnsDSCFunctionsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot process null Ast. - /// - internal static string NullAstErrorMessage { - get { - return ResourceManager.GetString("NullAstErrorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot process null CommandInfo. - /// - internal static string NullCommandInfoError { - get { - return ResourceManager.GetString("NullCommandInfoError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Error Message is Null.. - /// - internal static string NullErrorMessage { - get { - return ResourceManager.GetString("NullErrorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to One Char. - /// - internal static string OneCharCommonName { - get { - return ResourceManager.GetString("OneCharCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that cmdlets and parameters have more than one character.. - /// - internal static string OneCharDescription { - get { - return ResourceManager.GetString("OneCharDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet name '{0}' only has one character.. - /// - internal static string OneCharErrorCmdlet { - get { - return ResourceManager.GetString("OneCharErrorCmdlet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' has a parameter '{1}' that only has one character.. - /// - internal static string OneCharErrorParameter { - get { - return ResourceManager.GetString("OneCharErrorParameter", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A script block has a parameter '{0}' that only has one character.. - /// - internal static string OneCharErrorParameterSB { - get { - return ResourceManager.GetString("OneCharErrorParameterSB", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to OneChar. - /// - internal static string OneCharName { - get { - return ResourceManager.GetString("OneCharName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place close braces. - /// - internal static string PlaceCloseBraceCommonName { - get { - return ResourceManager.GetString("PlaceCloseBraceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace should be on a new line by itself.. - /// - internal static string PlaceCloseBraceDescription { - get { - return ResourceManager.GetString("PlaceCloseBraceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace is not on a new line.. - /// - internal static string PlaceCloseBraceErrorShouldBeOnNewLine { - get { - return ResourceManager.GetString("PlaceCloseBraceErrorShouldBeOnNewLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace before a branch statement is followed by a new line.. - /// - internal static string PlaceCloseBraceErrorShouldCuddleBranchStatement { - get { - return ResourceManager.GetString("PlaceCloseBraceErrorShouldCuddleBranchStatement", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace does not follow a new line.. - /// - internal static string PlaceCloseBraceErrorShouldFollowNewLine { - get { - return ResourceManager.GetString("PlaceCloseBraceErrorShouldFollowNewLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Close brace does not follow a non-empty line.. - /// - internal static string PlaceCloseBraceErrorShouldNotFollowEmptyLine { - get { - return ResourceManager.GetString("PlaceCloseBraceErrorShouldNotFollowEmptyLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PlaceCloseBrace. - /// - internal static string PlaceCloseBraceName { - get { - return ResourceManager.GetString("PlaceCloseBraceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place open braces consistently. - /// - internal static string PlaceOpenBraceCommonName { - get { - return ResourceManager.GetString("PlaceOpenBraceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place open braces either on the same line as the preceding expression or on a new line.. - /// - internal static string PlaceOpenBraceDescription { - get { - return ResourceManager.GetString("PlaceOpenBraceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There is no new line after open brace.. - /// - internal static string PlaceOpenBraceErrorNoNewLineAfterBrace { - get { - return ResourceManager.GetString("PlaceOpenBraceErrorNoNewLineAfterBrace", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Open brace not on same line as preceding keyword. It should be on the same line.. - /// - internal static string PlaceOpenBraceErrorShouldBeOnSameLine { - get { - return ResourceManager.GetString("PlaceOpenBraceErrorShouldBeOnSameLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Open brace is not on a new line.. - /// - internal static string PlaceOpenBraceErrorShouldNotBeOnSameLine { - get { - return ResourceManager.GetString("PlaceOpenBraceErrorShouldNotBeOnSameLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PlaceOpenBrace. - /// - internal static string PlaceOpenBraceName { - get { - return ResourceManager.GetString("PlaceOpenBraceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Null Comparison. - /// - internal static string PossibleIncorrectComparisonWithNullCommonName { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that $null is on the left side of any equaltiy comparisons (eq, ne, ceq, cne, ieq, ine). When there is an array on the left side of a null equality comparison, PowerShell will check for a $null IN the array rather than if the array is null. If the two sides of the comaprision are switched this is fixed. Therefore, $null should always be on the left side of equality comparisons just in case.. - /// - internal static string PossibleIncorrectComparisonWithNullDescription { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to $null should be on the left side of equality comparisons.. - /// - internal static string PossibleIncorrectComparisonWithNullError { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PossibleIncorrectComparisonWithNull. - /// - internal static string PossibleIncorrectComparisonWithNullName { - get { - return ResourceManager.GetString("PossibleIncorrectComparisonWithNullName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '=' operator means assignment. Did you mean the equal operator '-eq'?. - /// - internal static string PossibleIncorrectUsageOfAssignmentOperatorCommonName { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfAssignmentOperatorCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Did you really mean to make an assignment inside an if statement? If you rather meant to check for equality, use the '-eq' operator.. - /// - internal static string PossibleIncorrectUsageOfAssignmentOperatorError { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfAssignmentOperatorError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PossibleIncorrectUsageOfAssignmentOperator. - /// - internal static string PossibleIncorrectUsageOfAssignmentOperatorName { - get { - return ResourceManager.GetString("PossibleIncorrectUsageOfAssignmentOperatorName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Basic Comment Help. - /// - internal static string ProvideCommentHelpCommonName { - get { - return ResourceManager.GetString("ProvideCommentHelpCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that all cmdlets have a help comment. This rule only checks existence. It does not check the content of the comment.. - /// - internal static string ProvideCommentHelpDescription { - get { - return ResourceManager.GetString("ProvideCommentHelpDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' does not have a help comment.. - /// - internal static string ProvideCommentHelpError { - get { - return ResourceManager.GetString("ProvideCommentHelpError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ProvideCommentHelp. - /// - internal static string ProvideCommentHelpName { - get { - return ResourceManager.GetString("ProvideCommentHelpName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reserved Cmdlet Chars. - /// - internal static string ReservedCmdletCharCommonName { - get { - return ResourceManager.GetString("ReservedCmdletCharCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks for reserved characters in cmdlet names. These characters usually cause a parsing error. Otherwise they will generally cause runtime errors.. - /// - internal static string ReservedCmdletCharDescription { - get { - return ResourceManager.GetString("ReservedCmdletCharDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' uses a reserved char in its name.. - /// - internal static string ReservedCmdletCharError { - get { - return ResourceManager.GetString("ReservedCmdletCharError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ReservedCmdletChar. - /// - internal static string ReservedCmdletCharName { - get { - return ResourceManager.GetString("ReservedCmdletCharName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}'. - /// - internal static string ReservedParamsCmdletPrefix { - get { - return ResourceManager.GetString("ReservedParamsCmdletPrefix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reserved Parameters. - /// - internal static string ReservedParamsCommonName { - get { - return ResourceManager.GetString("ReservedParamsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks for reserved parameters in function definitions. If these parameters are defined by the user, an error generally occurs.. - /// - internal static string ReservedParamsDescription { - get { - return ResourceManager.GetString("ReservedParamsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' defines the reserved common parameter '{1}'.. - /// - internal static string ReservedParamsError { - get { - return ResourceManager.GetString("ReservedParamsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ReservedParams. - /// - internal static string ReservedParamsName { - get { - return ResourceManager.GetString("ReservedParamsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The script. - /// - internal static string ReservedParamsScriptPrefix { - get { - return ResourceManager.GetString("ReservedParamsScriptPrefix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to #,(){}[]&/\\$^;:\"'<>|?@`*%+=~. - /// - internal static string ReserverCmdletChars { - get { - return ResourceManager.GetString("ReserverCmdletChars", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ReturnCorrectTypesForDSCFunctions. - /// - internal static string ReturnCorrectTypeDSCFunctionsName { - get { - return ResourceManager.GetString("ReturnCorrectTypeDSCFunctionsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Return Correct Types For DSC Functions. - /// - internal static string ReturnCorrectTypesForDSCFunctionsCommonName { - get { - return ResourceManager.GetString("ReturnCorrectTypesForDSCFunctionsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set function in DSC class and Set-TargetResource in DSC resource must not return anything. Get function in DSC class must return an instance of the DSC class and Get-TargetResource function in DSC resource must return a hashtable. Test function in DSC class and Get-TargetResource function in DSC resource must return a boolean.. - /// - internal static string ReturnCorrectTypesForDSCFunctionsDescription { - get { - return ResourceManager.GetString("ReturnCorrectTypesForDSCFunctionsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} function in DSC Class {1} should return object of type {2}. - /// - internal static string ReturnCorrectTypesForDSCFunctionsNoTypeError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForDSCFunctionsNoTypeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} function in DSC Class {1} should return object of type {2} instead of type {3}. - /// - internal static string ReturnCorrectTypesForDSCFunctionsWrongTypeError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForDSCFunctionsWrongTypeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} function in DSC Resource should return object of type {1} instead of {2}. - /// - internal static string ReturnCorrectTypesForGetTestTargetResourceFunctionsDSCResourceError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForGetTestTargetResourceFunctionsDSCResourceError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set function in DSC Class {0} should not return anything. - /// - internal static string ReturnCorrectTypesForSetFunctionsDSCError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForSetFunctionsDSCError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Set-TargetResource function in DSC Resource should not output anything to the pipeline.. - /// - internal static string ReturnCorrectTypesForSetTargetResourceFunctionsDSCError { - get { - return ResourceManager.GetString("ReturnCorrectTypesForSetTargetResourceFunctionsDSCError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ScriptDefinition. - /// - internal static string ScriptDefinitionName { - get { - return ResourceManager.GetString("ScriptDefinitionName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to www.sharepoint.com. - /// - internal static string SharepointURL { - get { - return ResourceManager.GetString("SharepointURL", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Should Process. - /// - internal static string ShouldProcessCommonName { - get { - return ResourceManager.GetString("ShouldProcessCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that if the SupportsShouldProcess is present, the function calls ShouldProcess/ShouldContinue and vice versa. Scripts with one or the other but not both will generally run into an error or unexpected behavior.. - /// - internal static string ShouldProcessDescription { - get { - return ResourceManager.GetString("ShouldProcessDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' has the ShouldProcess attribute but does not call ShouldProcess/ShouldContinue.. - /// - internal static string ShouldProcessErrorHasAttribute { - get { - return ResourceManager.GetString("ShouldProcessErrorHasAttribute", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A script block has the ShouldProcess attribute but does not call ShouldProcess/ShouldContinue.. - /// - internal static string ShouldProcessErrorHasAttributeSB { - get { - return ResourceManager.GetString("ShouldProcessErrorHasAttributeSB", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' calls ShouldProcess/ShouldContinue but does not have the ShouldProcess attribute.. - /// - internal static string ShouldProcessErrorHasCmdlet { - get { - return ResourceManager.GetString("ShouldProcessErrorHasCmdlet", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A script block calls ShouldProcess/ShouldContinue but does not have the ShouldProcess attribute.. - /// - internal static string ShouldProcessErrorHasCmdletSB { - get { - return ResourceManager.GetString("ShouldProcessErrorHasCmdletSB", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ShouldProcess. - /// - internal static string ShouldProcessName { - get { - return ResourceManager.GetString("ShouldProcessName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PS. - /// - internal static string SourceName { - get { - return ResourceManager.GetString("SourceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type Not Found. - /// - internal static string TypeNotFoundCommonName { - get { - return ResourceManager.GetString("TypeNotFoundCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Undefined type should not be used. - /// - internal static string TypeNotFoundDescription { - get { - return ResourceManager.GetString("TypeNotFoundDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type '{0}' is not found. Please check that it is defined.. - /// - internal static string TypeNotFoundError { - get { - return ResourceManager.GetString("TypeNotFoundError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to TypeNotFound. - /// - internal static string TypeNotFoundName { - get { - return ResourceManager.GetString("TypeNotFoundName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet Verbs. - /// - internal static string UseApprovedVerbsCommonName { - get { - return ResourceManager.GetString("UseApprovedVerbsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Checks that all defined cmdlets use approved verbs. This is in line with PowerShell's best practices.. - /// - internal static string UseApprovedVerbsDescription { - get { - return ResourceManager.GetString("UseApprovedVerbsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' uses an unapproved verb.. - /// - internal static string UseApprovedVerbsError { - get { - return ResourceManager.GetString("UseApprovedVerbsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseApprovedVerbs. - /// - internal static string UseApprovedVerbsName { - get { - return ResourceManager.GetString("UseApprovedVerbsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use BOM encoding for non-ASCII files. - /// - internal static string UseBOMForUnicodeEncodedFileCommonName { - get { - return ResourceManager.GetString("UseBOMForUnicodeEncodedFileCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to For a file encoded with a format other than ASCII, ensure BOM is present to ensure that any application consuming this file can interpret it correctly.. - /// - internal static string UseBOMForUnicodeEncodedFileDescription { - get { - return ResourceManager.GetString("UseBOMForUnicodeEncodedFileDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Missing BOM encoding for non-ASCII encoded file '{0}'. - /// - internal static string UseBOMForUnicodeEncodedFileError { - get { - return ResourceManager.GetString("UseBOMForUnicodeEncodedFileError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseBOMForUnicodeEncodedFile. - /// - internal static string UseBOMForUnicodeEncodedFileName { - get { - return ResourceManager.GetString("UseBOMForUnicodeEncodedFileName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use Cmdlet Correctly. - /// - internal static string UseCmdletCorrectlyCommonName { - get { - return ResourceManager.GetString("UseCmdletCorrectlyCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet should be called with the mandatory parameters.. - /// - internal static string UseCmdletCorrectlyDescription { - get { - return ResourceManager.GetString("UseCmdletCorrectlyDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet '{0}' may be used incorrectly. Please check that all mandatory parameters are supplied.. - /// - internal static string UseCmdletCorrectlyError { - get { - return ResourceManager.GetString("UseCmdletCorrectlyError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseCmdletCorrectly. - /// - internal static string UseCmdletCorrectlyName { - get { - return ResourceManager.GetString("UseCmdletCorrectlyName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use compatible cmdlets. - /// - internal static string UseCompatibleCmdletsCommonName { - get { - return ResourceManager.GetString("UseCompatibleCmdletsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use cmdlets compatible with the given PowerShell version and edition and operating system. - /// - internal static string UseCompatibleCmdletsDescription { - get { - return ResourceManager.GetString("UseCompatibleCmdletsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' is not compatible with PowerShell edition '{1}', version '{2}' and OS '{3}'. - /// - internal static string UseCompatibleCmdletsError { - get { - return ResourceManager.GetString("UseCompatibleCmdletsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseCompatibleCmdlets. - /// - internal static string UseCompatibleCmdletsName { - get { - return ResourceManager.GetString("UseCompatibleCmdletsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use consistent indentation. - /// - internal static string UseConsistentIndentationCommonName { - get { - return ResourceManager.GetString("UseConsistentIndentationCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each statement block should have a consistent indenation.. - /// - internal static string UseConsistentIndentationDescription { - get { - return ResourceManager.GetString("UseConsistentIndentationDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Indentation not consistent. - /// - internal static string UseConsistentIndentationError { - get { - return ResourceManager.GetString("UseConsistentIndentationError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseConsistentIndentation. - /// - internal static string UseConsistentIndentationName { - get { - return ResourceManager.GetString("UseConsistentIndentationName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use whitespaces. - /// - internal static string UseConsistentWhitespaceCommonName { - get { - return ResourceManager.GetString("UseConsistentWhitespaceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Check for whitespace between keyword and open paren/curly, around assigment operator ('='), around arithmetic operators and after separators (',' and ';'). - /// - internal static string UseConsistentWhitespaceDescription { - get { - return ResourceManager.GetString("UseConsistentWhitespaceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space before open brace.. - /// - internal static string UseConsistentWhitespaceErrorBeforeBrace { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorBeforeBrace", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space before open parenthesis.. - /// - internal static string UseConsistentWhitespaceErrorBeforeParen { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorBeforeParen", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space before and after binary and assignment operators.. - /// - internal static string UseConsistentWhitespaceErrorOperator { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorOperator", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space after a comma.. - /// - internal static string UseConsistentWhitespaceErrorSeparatorComma { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorSeparatorComma", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use space after a semicolon.. - /// - internal static string UseConsistentWhitespaceErrorSeparatorSemi { - get { - return ResourceManager.GetString("UseConsistentWhitespaceErrorSeparatorSemi", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseConsistentWhitespace. - /// - internal static string UseConsistentWhitespaceName { - get { - return ResourceManager.GetString("UseConsistentWhitespaceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Extra Variables. - /// - internal static string UseDeclaredVarsMoreThanAssignmentsCommonName { - get { - return ResourceManager.GetString("UseDeclaredVarsMoreThanAssignmentsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Ensure declared variables are used elsewhere in the script and not just during assignment.. - /// - internal static string UseDeclaredVarsMoreThanAssignmentsDescription { - get { - return ResourceManager.GetString("UseDeclaredVarsMoreThanAssignmentsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The variable '{0}' is assigned but never used.. - /// - internal static string UseDeclaredVarsMoreThanAssignmentsError { - get { - return ResourceManager.GetString("UseDeclaredVarsMoreThanAssignmentsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseDeclaredVarsMoreThanAssignments. - /// - internal static string UseDeclaredVarsMoreThanAssignmentsName { - get { - return ResourceManager.GetString("UseDeclaredVarsMoreThanAssignmentsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use identical mandatory parameters for DSC Get/Test/Set TargetResource functions. - /// - internal static string UseIdenticalMandatoryParametersDSCCommonName { - get { - return ResourceManager.GetString("UseIdenticalMandatoryParametersDSCCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Get/Test/Set TargetResource functions of DSC resource must have the same mandatory parameters.. - /// - internal static string UseIdenticalMandatoryParametersDSCDescription { - get { - return ResourceManager.GetString("UseIdenticalMandatoryParametersDSCDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The '{0}' parameter '{1}' is not present in '{2}' DSC resource function(s).. - /// - internal static string UseIdenticalMandatoryParametersDSCError { - get { - return ResourceManager.GetString("UseIdenticalMandatoryParametersDSCError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseIdenticalMandatoryParametersForDSC. - /// - internal static string UseIdenticalMandatoryParametersDSCName { - get { - return ResourceManager.GetString("UseIdenticalMandatoryParametersDSCName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use Identical Parameters For DSC Test and Set Functions. - /// - internal static string UseIdenticalParametersDSCCommonName { - get { - return ResourceManager.GetString("UseIdenticalParametersDSCCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Test and Set-TargetResource functions of DSC Resource must have the same parameters.. - /// - internal static string UseIdenticalParametersDSCDescription { - get { - return ResourceManager.GetString("UseIdenticalParametersDSCDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Test and Set-TargetResource functions of DSC Resource must have the same parameters.. - /// - internal static string UseIdenticalParametersDSCError { - get { - return ResourceManager.GetString("UseIdenticalParametersDSCError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseIdenticalParametersForDSC. - /// - internal static string UseIdenticalParametersDSCName { - get { - return ResourceManager.GetString("UseIdenticalParametersDSCName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create hashtables with literal initializers. - /// - internal static string UseLiteralInitilializerForHashtableCommonName { - get { - return ResourceManager.GetString("UseLiteralInitilializerForHashtableCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use literal initializer, @{{}}, for creating a hashtable as they are case-insensitive by default. - /// - internal static string UseLiteralInitilializerForHashtableDescription { - get { - return ResourceManager.GetString("UseLiteralInitilializerForHashtableDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create hashtables with literal initliazers. - /// - internal static string UseLiteralInitilializerForHashtableError { - get { - return ResourceManager.GetString("UseLiteralInitilializerForHashtableError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseLiteralInitializerForHashtable. - /// - internal static string UseLiteralInitilializerForHashtableName { - get { - return ResourceManager.GetString("UseLiteralInitilializerForHashtableName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use OutputType Correctly. - /// - internal static string UseOutputTypeCorrectlyCommonName { - get { - return ResourceManager.GetString("UseOutputTypeCorrectlyCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The return types of a cmdlet should be declared using the OutputType attribute.. - /// - internal static string UseOutputTypeCorrectlyDescription { - get { - return ResourceManager.GetString("UseOutputTypeCorrectlyDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' returns an object of type '{1}' but this type is not declared in the OutputType attribute.. - /// - internal static string UseOutputTypeCorrectlyError { - get { - return ResourceManager.GetString("UseOutputTypeCorrectlyError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseOutputTypeCorrectly. - /// - internal static string UseOutputTypeCorrectlyName { - get { - return ResourceManager.GetString("UseOutputTypeCorrectlyName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use PSCredential type.. - /// - internal static string UsePSCredentialTypeCommonName { - get { - return ResourceManager.GetString("UsePSCredentialTypeCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to For PowerShell 4.0 and earlier, a parameter named Credential with type PSCredential must have a credential transformation attribute defined after the PSCredential type attribute. . - /// - internal static string UsePSCredentialTypeDescription { - get { - return ResourceManager.GetString("UsePSCredentialTypeDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Credential parameter in '{0}' must be of type PSCredential. For PowerShell 4.0 and earlier, please define a credential transformation attribute, e.g. [System.Management.Automation.Credential()], after the PSCredential type attribute.. - /// - internal static string UsePSCredentialTypeError { - get { - return ResourceManager.GetString("UsePSCredentialTypeError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Credential parameter found in the script block must be of type PSCredential. For PowerShell 4.0 and earlier please define a credential transformation attribute, e.g. [System.Management.Automation.Credential()], after the PSCredential type attribute. . - /// - internal static string UsePSCredentialTypeErrorSB { - get { - return ResourceManager.GetString("UsePSCredentialTypeErrorSB", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UsePSCredentialType. - /// - internal static string UsePSCredentialTypeName { - get { - return ResourceManager.GetString("UsePSCredentialTypeName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use ShouldProcess For State Changing Functions. - /// - internal static string UseShouldProcessForStateChangingFunctionsCommonName { - get { - return ResourceManager.GetString("UseShouldProcessForStateChangingFunctionsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Functions that have verbs like New, Start, Stop, Set, Reset, Restart that change system state should support 'ShouldProcess'.. - /// - internal static string UseShouldProcessForStateChangingFunctionsDescrption { - get { - return ResourceManager.GetString("UseShouldProcessForStateChangingFunctionsDescrption", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Function '{0}' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.. - /// - internal static string UseShouldProcessForStateChangingFunctionsError { - get { - return ResourceManager.GetString("UseShouldProcessForStateChangingFunctionsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseShouldProcessForStateChangingFunctions. - /// - internal static string UseShouldProcessForStateChangingFunctionsName { - get { - return ResourceManager.GetString("UseShouldProcessForStateChangingFunctionsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet Singular Noun. - /// - internal static string UseSingularNounsCommonName { - get { - return ResourceManager.GetString("UseSingularNounsCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cmdlet should use singular instead of plural nouns.. - /// - internal static string UseSingularNounsDescription { - get { - return ResourceManager.GetString("UseSingularNounsDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The cmdlet '{0}' uses a plural noun. A singular noun should be used instead.. - /// - internal static string UseSingularNounsError { - get { - return ResourceManager.GetString("UseSingularNounsError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseSingularNouns. - /// - internal static string UseSingularNounsName { - get { - return ResourceManager.GetString("UseSingularNounsName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Missing '{0}' function. DSC Class must implement Get, Set and Test functions.. - /// - internal static string UseStandardDSCFunctionsInClassError { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInClassError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use Standard Get/Set/Test TargetResource functions in DSC Resource . - /// - internal static string UseStandardDSCFunctionsInResourceCommonName { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInResourceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DSC Resource must implement Get, Set and Test-TargetResource functions. DSC Class must implement Get, Set and Test functions.. - /// - internal static string UseStandardDSCFunctionsInResourceDescription { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInResourceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Missing '{0}' function. DSC Resource must implement Get, Set and Test-TargetResource functions.. - /// - internal static string UseStandardDSCFunctionsInResourceError { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInResourceError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to StandardDSCFunctionsInResource. - /// - internal static string UseStandardDSCFunctionsInResourceName { - get { - return ResourceManager.GetString("UseStandardDSCFunctionsInResourceName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use SupportsShouldProcess. - /// - internal static string UseSupportsShouldProcessCommonName { - get { - return ResourceManager.GetString("UseSupportsShouldProcessCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Commands typically provide Confirm and Whatif parameters to give more control on its execution in an interactive environment. In PowerShell, a command can use a SupportsShouldProcess attribute to provide this capability. Hence, manual addition of these parameters to a command is discouraged. If a commands need Confirm and Whatif parameters, then it should support ShouldProcess.. - /// - internal static string UseSupportsShouldProcessDescription { - get { - return ResourceManager.GetString("UseSupportsShouldProcessDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Whatif and/or Confirm manually defined in function {0}. Instead, please use SupportsShouldProcess attribute.. - /// - internal static string UseSupportsShouldProcessError { - get { - return ResourceManager.GetString("UseSupportsShouldProcessError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseSupportsShouldProcess. - /// - internal static string UseSupportsShouldProcessName { - get { - return ResourceManager.GetString("UseSupportsShouldProcessName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use the *ToExport module manifest fields.. - /// - internal static string UseToExportFieldsInManifestCommonName { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace {0} with {1}. - /// - internal static string UseToExportFieldsInManifestCorrectionDescription { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestCorrectionDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to In a module manifest, AliasesToExport, CmdletsToExport, FunctionsToExport and VariablesToExport fields should not use wildcards or $null in their entries. During module auto-discovery, if any of these entries are missing or $null or wildcard, PowerShell does some potentially expensive work to analyze the rest of the module.. - /// - internal static string UseToExportFieldsInManifestDescription { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not use wildcard or $null in this field. Explicitly specify a list for {0}. . - /// - internal static string UseToExportFieldsInManifestError { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseToExportFieldsInManifest. - /// - internal static string UseToExportFieldsInManifestName { - get { - return ResourceManager.GetString("UseToExportFieldsInManifestName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use Type At Variable Assignment. - /// - internal static string UseTypeAtVariableAssignmentCommonName { - get { - return ResourceManager.GetString("UseTypeAtVariableAssignmentCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Types should be specified at variable assignments to maintain readability and maintainability of script.. - /// - internal static string UseTypeAtVariableAssignmentDescription { - get { - return ResourceManager.GetString("UseTypeAtVariableAssignmentDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Specify type at the assignment of variable '{0}'. - /// - internal static string UseTypeAtVariableAssignmentError { - get { - return ResourceManager.GetString("UseTypeAtVariableAssignmentError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseTypeAtVariableAssignment. - /// - internal static string UseTypeAtVariableAssignmentName { - get { - return ResourceManager.GetString("UseTypeAtVariableAssignmentName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use UTF8 Encoding For Help File. - /// - internal static string UseUTF8EncodingForHelpFileCommonName { - get { - return ResourceManager.GetString("UseUTF8EncodingForHelpFileCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to PowerShell help file needs to use UTF8 Encoding.. - /// - internal static string UseUTF8EncodingForHelpFileDescription { - get { - return ResourceManager.GetString("UseUTF8EncodingForHelpFileDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File {0} has to use UTF8 instead of {1} encoding because it is a powershell help file.. - /// - internal static string UseUTF8EncodingForHelpFileError { - get { - return ResourceManager.GetString("UseUTF8EncodingForHelpFileError", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseUTF8EncodingForHelpFile. - /// - internal static string UseUTF8EncodingForHelpFileName { - get { - return ResourceManager.GetString("UseUTF8EncodingForHelpFileName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use verbose message in DSC resource. - /// - internal static string UseVerboseMessageInDSCResourceCommonName { - get { - return ResourceManager.GetString("UseVerboseMessageInDSCResourceCommonName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to It is a best practice to emit informative, verbose messages in DSC resource functions. This helps in debugging issues when a DSC configuration is executed.. - /// - internal static string UseVerboseMessageInDSCResourceDescription { - get { - return ResourceManager.GetString("UseVerboseMessageInDSCResourceDescription", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There is no call to Write-Verbose in DSC function '{0}'. If you are using Write-Verbose in a helper function, suppress this rule application.. - /// - internal static string UseVerboseMessageInDSCResourceErrorFunction { - get { - return ResourceManager.GetString("UseVerboseMessageInDSCResourceErrorFunction", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to UseVerboseMessageInDSCResource. - /// - internal static string UseVerboseMessageInDSCResourceName { - get { - return ResourceManager.GetString("UseVerboseMessageInDSCResourceName", resourceCulture); - } - } - } -} diff --git a/Rules/Strings.resx b/Rules/resources/Strings.resx similarity index 100% rename from Rules/Strings.resx rename to Rules/resources/Strings.resx diff --git a/Tests/DisabledRules/CommandNotFound.tests.ps1 b/Tests/DisabledRules/CommandNotFound.tests.ps1 index e311fdca5..8cf0569c2 100644 --- a/Tests/DisabledRules/CommandNotFound.tests.ps1 +++ b/Tests/DisabledRules/CommandNotFound.tests.ps1 @@ -1,4 +1,4 @@ -Import-Module -Verbose ScriptAnalyzer +Import-Module ScriptAnalyzer $violationMessage = "Command Get-WrongCommand Is Not Found" $violationName = "PSCommandNotFound" $directory = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -26,4 +26,4 @@ Describe "CommandNotFound" { $noViolationsDSC.Count | Should -Be 0 } } -} \ No newline at end of file +} diff --git a/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 b/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 index 4877becdc..f3905ed3b 100644 --- a/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 +++ b/Tests/Engine/GetScriptAnalyzerRule.tests.ps1 @@ -1,6 +1,6 @@  $directory = Split-Path -Parent $MyInvocation.MyCommand.Path -Import-Module -Verbose PSScriptAnalyzer +Import-Module PSScriptAnalyzer $testRootDirectory = Split-Path -Parent $directory Import-Module (Join-Path $testRootDirectory 'PSScriptAnalyzerTestHelper.psm1') $sa = Get-Command Get-ScriptAnalyzerRule diff --git a/Tests/Engine/GlobalSuppression.test.ps1 b/Tests/Engine/GlobalSuppression.test.ps1 index 74e23fc48..f799297b2 100644 --- a/Tests/Engine/GlobalSuppression.test.ps1 +++ b/Tests/Engine/GlobalSuppression.test.ps1 @@ -3,7 +3,7 @@ # accident if (!(Get-Module PSScriptAnalyzer) -and !$testingLibraryUsage) { - Import-Module -Verbose PSScriptAnalyzer + Import-Module PSScriptAnalyzer } $directory = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -102,4 +102,4 @@ Describe "GlobalSuppression" { $Error[0].FullyQualifiedErrorId | Should -Match "WrongSettingsKey,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand" } } -} \ No newline at end of file +} diff --git a/Tests/Engine/RuleSuppression.tests.ps1 b/Tests/Engine/RuleSuppression.tests.ps1 index 84b342f72..c87c23e24 100644 --- a/Tests/Engine/RuleSuppression.tests.ps1 +++ b/Tests/Engine/RuleSuppression.tests.ps1 @@ -3,7 +3,7 @@ # accident if (!(Get-Module PSScriptAnalyzer) -and !$testingLibraryUsage) { - Import-Module -Verbose PSScriptAnalyzer + Import-Module PSScriptAnalyzer } $directory = Split-Path -Parent $MyInvocation.MyCommand.Path diff --git a/Tests/Engine/RuleSuppressionClass.tests.ps1 b/Tests/Engine/RuleSuppressionClass.tests.ps1 index d06f35039..98223468d 100644 --- a/Tests/Engine/RuleSuppressionClass.tests.ps1 +++ b/Tests/Engine/RuleSuppressionClass.tests.ps1 @@ -5,7 +5,7 @@ # accident if (!(Get-Module PSScriptAnalyzer) -and !$testingLibraryUsage) { - Import-Module -Verbose PSScriptAnalyzer + Import-Module PSScriptAnalyzer } $directory = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -70,4 +70,4 @@ Describe "RuleSuppressionWithScope" { } } } - } \ No newline at end of file + } diff --git a/Tests/Rules/DscExamplesPresent.tests.ps1 b/Tests/Rules/DscExamplesPresent.tests.ps1 index b3c420243..0ff74d812 100644 --- a/Tests/Rules/DscExamplesPresent.tests.ps1 +++ b/Tests/Rules/DscExamplesPresent.tests.ps1 @@ -1,4 +1,4 @@ -Import-Module -Verbose PSScriptAnalyzer +Import-Module PSScriptAnalyzer $currentPath = Split-Path -Parent $MyInvocation.MyCommand.Path $ruleName = "PSDSCDscExamplesPresent" diff --git a/Tests/Rules/DscTestsPresent.tests.ps1 b/Tests/Rules/DscTestsPresent.tests.ps1 index 603f94d3d..9c90cf068 100644 --- a/Tests/Rules/DscTestsPresent.tests.ps1 +++ b/Tests/Rules/DscTestsPresent.tests.ps1 @@ -1,4 +1,4 @@ -Import-Module -Verbose PSScriptAnalyzer +Import-Module PSScriptAnalyzer $currentPath = Split-Path -Parent $MyInvocation.MyCommand.Path $ruleName = "PSDSCDscTestsPresent" diff --git a/Tests/Rules/ReturnCorrectTypesForDSCFunctions.tests.ps1 b/Tests/Rules/ReturnCorrectTypesForDSCFunctions.tests.ps1 index 47f190410..fd842b139 100644 --- a/Tests/Rules/ReturnCorrectTypesForDSCFunctions.tests.ps1 +++ b/Tests/Rules/ReturnCorrectTypesForDSCFunctions.tests.ps1 @@ -1,4 +1,4 @@ -Import-Module -Verbose PSScriptAnalyzer +Import-Module PSScriptAnalyzer $violationMessageDSCResource = "Test-TargetResource function in DSC Resource should return object of type System.Boolean instead of System.Collections.Hashtable" $violationMessageDSCClass = "Get function in DSC Class FileResource should return object of type FileResource instead of type System.Collections.Hashtable" diff --git a/Tests/Rules/UseCmdletCorrectly.tests.ps1 b/Tests/Rules/UseCmdletCorrectly.tests.ps1 index 7447eceb2..3cde8ecc8 100644 --- a/Tests/Rules/UseCmdletCorrectly.tests.ps1 +++ b/Tests/Rules/UseCmdletCorrectly.tests.ps1 @@ -1,4 +1,4 @@ -Import-Module -Verbose PSScriptAnalyzer +Import-Module PSScriptAnalyzer $violationMessage = "Cmdlet 'Write-Warning' may be used incorrectly. Please check that all mandatory parameters are supplied." $violationName = "PSUseCmdletCorrectly" $directory = Split-Path -Parent $MyInvocation.MyCommand.Path @@ -21,4 +21,4 @@ Describe "UseCmdletCorrectly" { $noViolations.Count | Should -Be 0 } } -} \ No newline at end of file +} diff --git a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 index e1fb10600..8a01db9e1 100644 --- a/Tests/Rules/UseDSCResourceFunctions.tests.ps1 +++ b/Tests/Rules/UseDSCResourceFunctions.tests.ps1 @@ -1,4 +1,4 @@ -Import-Module -Verbose PSScriptAnalyzer +Import-Module PSScriptAnalyzer $violationMessage = "Missing 'Get-TargetResource' function. DSC Resource must implement Get, Set and Test-TargetResource functions." $classViolationMessage = "Missing 'Set' function. DSC Class must implement Get, Set and Test functions." diff --git a/appveyor.yml b/appveyor.yml index 9e5302718..94d462a44 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,9 +52,9 @@ build_script: Write-Verbose ".NET SDK version: $(dotnet --version)" -Verbose Push-Location C:\projects\psscriptanalyzer # Test build using netstandard to test whether APIs are being called that are not available in .Net Core. Remove output afterwards. - .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build + .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build -ResGen git clean -dfx - C:\projects\psscriptanalyzer\buildCoreClr.ps1 -Framework net451 -Configuration $env:BuildConfiguration -Build + C:\projects\psscriptanalyzer\buildCoreClr.ps1 -Framework net451 -Configuration $env:BuildConfiguration -Build -ResGen C:\projects\psscriptanalyzer\build.ps1 -BuildDocs Pop-Location diff --git a/buildCoreClr.ps1 b/buildCoreClr.ps1 index e9655e24c..83106bfe1 100644 --- a/buildCoreClr.ps1 +++ b/buildCoreClr.ps1 @@ -42,7 +42,6 @@ elseif ($Configuration -match 'PSv3') { if ($build) { - Write-Progress "Building Engine" Push-Location Engine\ dotnet build Engine.csproj --framework $Framework --configuration $Configuration diff --git a/docs/dev-process/building.md b/docs/dev-process/building.md new file mode 100644 index 000000000..915b78c85 --- /dev/null +++ b/docs/dev-process/building.md @@ -0,0 +1,65 @@ +# Building and Testing ScriptAnalyzer + +### From Source + +* [.NET Core 2.1.4 SDK](https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.5-download.md) +* [PlatyPS 0.9.0 or greater](https://github.com/PowerShell/platyPS/releases) +* Recommended for development: [Visual Studio Code](https://code.visualstudio.com/download) +* Optionally for development: [Visual Studio](https://www.visualstudio.com/downloads/) + +#### Steps +* Obtain the source + - Download the latest source code from the [release page](https://github.com/PowerShell/PSScriptAnalyzer/releases) OR + - Clone the repository (needs git) + ```powershell + git clone https://github.com/PowerShell/PSScriptAnalyzer + ``` +* Navigate to the source directory + ```powershell + cd path/to/PSScriptAnalyzer + ``` +* Building + + * Windows PowerShell version 5.0 and greater + ```powershell + .\buildCoreClr.ps1 -Framework net451 -Configuration Release -Build + ``` + * Windows PowerShell version 3.0 and 4.0 + ```powershell + .\buildCoreClr.ps1 -Framework net451 -Configuration PSV3Release -Build + ``` + * PowerShell Core + ```powershell + .\buildCoreClr.ps1 -Framework netstandard1.6 -Configuration Release -Build + ``` +* Build documenatation + ```powershell + .\build.ps1 -BuildDocs + ``` +* Import the module +```powershell +Import-Module .\out\PSScriptAnalyzer +``` + +To confirm installation: run `Get-ScriptAnalyzerRule` in the PowerShell console to obtain the built-in rules + +### Resource changes +See [Resources](resx-files.md) + +### Testing + +Pester-based ScriptAnalyzer Tests are located in `path/to/PSScriptAnalyzer/Tests` folder. + +* Ensure [Pester 4.3.1](https://www.powershellgallery.com/packages/Pester/4.3.1) (or later) is installed +* Copy `path/to/PSScriptAnalyzer/out/PSScriptAnalyzer` to a folder in `PSModulePath` +* Go the Tests folder in your local repository +* Run Engine Tests: +``` PowerShell +cd /path/to/PSScriptAnalyzer/Tests/Engine +Invoke-Pester +``` +* Run Tests for Built-in rules: +``` PowerShell +cd /path/to/PSScriptAnalyzer/Tests/Rules +Invoke-Pester +`` diff --git a/docs/dev-process/coding-guidelines.md b/docs/dev-process/coding-guidelines.md new file mode 100644 index 000000000..576155f72 --- /dev/null +++ b/docs/dev-process/coding-guidelines.md @@ -0,0 +1,215 @@ +# C# Coding Guidelines + +## Coding Conventions + +As a general rule, our coding convention is to follow the style of the surrounding code. +So if a file happens to differ in style from conventions defined here +(e.g. private members are named `m_member` rather than `_member`), +the existing style in that file takes precedence. + +When making changes, you may find some existing code goes against the conventions defined here. +In such cases, please avoid reformatting any existing code when submitting a PR as it obscures the functional changes of the PR. +A separate PR should be submitted for style-only changes. +We also run the [.NET code formatter tool](https://github.com/dotnet/codeformatter) regularly to keep consistent formatting. + +### Naming Conventions + +* Use meaningful, descriptive words for names. + For method names, it's encouraged to use `VerbObject` pair such as **`LoadModule`**. + +* Use `_camelCase` to name internal and private fields and use `readonly` where possible. + Prefix instance fields with `_`, static fields with `s_` and thread static fields with `t_`. + When used on static fields, `readonly` should come after `static` (i.e. `static readonly` not `readonly static`). + +* Use `camelCase` to name non-constant local variables. + +* Use `PascalCase` to name constant local variables and fields. + The only exception is for interop code where the constant should exactly match the name and value of the code you are calling via interop (e.g. `const int ERROR_SUCCESS = 0`). + +* Use `PascalCase` to name types and all other type members. + +### Layout Conventions + +* Use four spaces of indentation (no tabs). + +* Avoid more than one blank empty line at any time. + +* Avoid trailing spaces at the end of a line. + +* Braces usually go on their own lines, + with the exception of single line statements that are properly indented. + +* Namespace imports should be specified at the top of the file, + outside of `namespace` declarations. + +* Fields should be specified at the top within type declarations. + For those that serve as backing fields for properties, + they should be specified next to the corresponding properties. + +* Preprocessor directives like `#if` and `#endif` should be placed at the beginning of a line, + without any leading spaces. + +* File encoding should be `UTF-8` without BOM. + All `BOM` encodings should be avoided. + Tests that need a `BOM` encoding file should generate the file on the fly. + +### Member Conventions + +* Use of `this` is neither encouraged nor discouraged. + +* Use `nameof()` instead of `""` whenever possible and relevant. + The motivation is to easily and more accurately find references. + +* Always specify the visibility, even if it's the default (i.e. `private string _foo` not `string _foo`). + Visibility should be the first modifier (i.e. `public abstract` not `abstract public`). + +* Make members private where possible. + Avoid declaring public members unless it's absolutely necessary. + +* Public members in a namespace that ends with `Internal`, + for example `System.Management.Automation.Internal` are not considered a supported public API. + Such members are necessarily public as implementation details in code shared between C# and PowerShell script, + or must be available publicly by generated code. + +### Commenting Conventions + +* Place the comment on a separate line, not at the end of a line of code. + +* Begin comment text with an uppercase letter. + It's recommended to end comment text with a period but not required. + +* Add comments where the code is not trivial or could be confusing. + +* Add comments where a reviewer needs help to understand the code. + +* Update/remove existing comments when you are changing the corresponding code. + +* Make sure the added/updated comments are meaningful, accurate and easy to understand. + +* Public members must use [doc comments](https://msdn.microsoft.com/en-us/library/b2s063f7.aspx). + Internal and private members may use doc comments but it is not required. + +## Performance Considerations + +The following guidelines are typically applied widely even in less important code because code and patterns are copied, +and we want certain inefficient code to stay out of the performance critical code. + +Some general guidelines: + +* Avoid LINQ - it can create lots of avoidable garbage. + Instead, iterate through a collection directly using `for` or `foreach` loop. + +* Between `for` and `foreach`, + `for` is slightly preferred when you're uncertain if `foreach` allocates an iterator. + +* Avoid `params` arrays, prefer adding overloads with 1, 2, 3, and maybe more parameters. + +* Be aware of APIs such as `String.Split(params char[])` that do not provide overloads to avoid array allocation. + When calling such APIs, reuse a static array when possible (e.g. `Utils.Separators.Colon`). + +* Avoid unnecessary memory allocation in a loop. + Move the memory allocation outside the loop if possible. + +* Avoid gratuitous exceptions as much as possible. + Exception handling can be expensive due to cache misses and page faults when accessing the handling code and data. + Finding and designing away exception-heavy code can result in a decent performance win. + For example, you should stay away from things like using exceptions for control flow. + +* Avoid `if (obj is Example) { example = (Example)obj }` when casting an object to a type. + Instead, use `var example = obj as Example` or the C# 7 syntax `if (obj is Example example) {...}` as appropriate. + In this way you can avoid converting to the type twice. + +* Use generic collections instead of the non-generic ones such as `ArrayList` and `Hashtable` to avoid type casting and unnecessary boxing whenever possible. + +* Use collection constructor overloads that take an initial capacity for collection types that have them. + Internally, `List`, `Dictionary`, + and the other generic collections use one or more arrays to hold valid data. + Whenever resizing is needed, + one or more new arrays double the size of existing arrays are created and items from the existing arrays are copied. + Setting an approximate initial capacity will reduce the number of resizing operations. + +* Use `dict.TryGetValue` instead of `dict.Contains` and `dict[..]` when retrieving value from a `Dictionary`. + In this way you can avoid hashing the key twice. + +* It's OK to use the `+` operator to concatenate one-off short strings. + But when dealing with strings in loops or large amounts of text, + use a `StringBuilder` object. + +## Security Considerations + +Security is an important aspect of PowerShell and we need to be very careful about changes that may introduce security risks, +such as code injection caused by the lack of input validation, +privilege escalation due to the misuse of impersonation, +or data privacy breach with a plain text password. + +Reviewers of a PR should be sensitive to changes that may affect security. +Some security related keywords may serve as good indicators, +such as `password`, `crypto`, `encryption`, `decryption`, `certificate`, `authenticate`, `ssl/tls` and `protected data`. + +When facing a PR with such changes, +the reviewers should request a designated security Subject Matter Expert (SME) to review the PR. +Currently, @PaulHigin and @TravisEz13 are our security SMEs. +See [CODEOWNERS](../../.github/CODEOWNERS) for more information about the area experts. + +## Best Practices + +* Avoid hard-coding anything unless it's absolutely necessary. + +* Avoid a method that is too long and complex. + In such case, separate it to multiple methods or even a nested class as you see fit. + +* Use `using` statement instead of `try/finally` if the only code in the `finally` block is to call the `Dispose` method. + +* Use of object initializers (e.g. `new Example { Name = "Name", ID = 1 }`) is encouraged for better readability, + but not required. + +* Stick to the `DRY` principle -- Don't Repeat Yourself. + * Wrap the commonly used code in methods, + or even put it in a utility class if that makes sense, + so that the same code can be reused (e.g. `StringToBase64Converter.Base64ToString(string)`). + * Check if the code for the same purpose already exists in the code base before inventing your own wheel. + * Avoid repeating literal strings in code. Instead, use `const` variable to hold the string. + * Resource strings used for errors or UI should be put in resource files (`.resx`) so that they can be localized later. + +* Use of new C# language syntax is encouraged. + But avoid refactoring any existing code using new language syntax when submitting a PR + as it obscures the functional changes of the PR. + A separate PR should be submitted for such refactoring without any functional changes. + +* Consider using the `Interlocked` class instead of the `lock` statement to atomically change simple states. The `Interlocked` class provides better performance for updates that must be atomic. + +* Here are some useful links for your reference: + * [Framework Design Guidelines](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/index) - Naming, Design and Usage guidelines including: + * [Arrays](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/arrays) + * [Collections](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/guidelines-for-collections) + * [Exceptions](https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/exceptions) + * [Best Practices for Developing World-Ready Applications](https://docs.microsoft.com/en-us/dotnet/standard/globalization-localization/best-practices-for-developing-world-ready-apps) - Unicode, Culture, Encoding and Localization. + * [Best Practices for Exceptions](https://docs.microsoft.com/en-us/dotnet/standard/exceptions/best-practices-for-exceptions) + * [Best Practices for Using Strings in .NET](https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings) + * [Best Practices for Regular Expressions in .NET](https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices) + * [Serialization Guidelines](https://docs.microsoft.com/en-us/dotnet/standard/serialization/serialization-guidelines) + * [Managed Threading Best Practices](https://docs.microsoft.com/en-us/dotnet/standard/threading/managed-threading-best-practices) + +## Portable Code + +There are 3 primary preprocessor macros we use during builds: + +* `DEBUG` - guard code that should not be included in release builds +* `CORECLR` - guard code that differs between Full CLR and CoreCLR +* `PSV3` - guard code that is specific to PowerShell version 3 + +Any other preprocessor defines found in the source are used for one-off custom builds, +typically to help debug specific scenarios. + +Here are some general guidelines for writing portable code: + +* Try to minimize the use of `#if UNIX`. + When absolutely necessary, avoid duplicating more code than necessary, + and instead prefer introducing helper functions to minimize the platform differences. + +* When adding platform dependent code (`Windows` vs. `UNIX`), prefer preprocessor directives over runtime checks. + However, runtime checks are acceptable if it would greatly improve readability + without causing performance concerns in performance-sensitive code. + +* We produce a single set of binaries for all variants (Windows and Non-Windows), + so runtime checks are currently necessary for some of them (e.g. macOS vs. Linux). diff --git a/docs/dev-process/release.md b/docs/dev-process/release.md new file mode 100644 index 000000000..8eac0560d --- /dev/null +++ b/docs/dev-process/release.md @@ -0,0 +1,18 @@ +# Creating a Release + +- Update changelog (`changelog.md`) with the new version number and change set. When updating the changelog please follow the same pattern as that of previous change sets (otherwise this may break the next step). +- Import the ReleaseMaker module and execute `New-Release` cmdlet to perform the following actions. + - Update module manifest (engine/PSScriptAnalyzer.psd1) with the new version number and change set + - Update the version number in `Engine/Engine.csproj` and `Rules/Rules.csproj` + - Create a release build in `out/` + - Build on a platform which supports both net451 and netstandard1.6 (Windows). + +```powershell + PS> Import-Module .\Utils\ReleaseMaker.psm1 + PS> New-Release +``` + +- Sign the binaries and PowerShell files in the release build and publish the module to [PowerShell Gallery](www.powershellgallery.com). +- Create a PR on `development` branch, with all the changes made in the previous step. +- Merge the changes to `development` and then merge `development` to `master` (Note that the `development` to `master` merge should be a `fast-forward` merge). +- Draft a new release on github and tag `master` with the new version number. diff --git a/docs/dev-process/resx-files.md b/docs/dev-process/resx-files.md new file mode 100644 index 000000000..21d66b7d2 --- /dev/null +++ b/docs/dev-process/resx-files.md @@ -0,0 +1,24 @@ +# Resources + +Resources are `.resx` files with string values that we use for error messages and such. +They live in `src\Engine\resources` and `src\Rules\resources` folders. + +At the moment `dotnet cli` doesn't support automatically generating C# bindings (strongly typed resource files). +Script analyzer resources are created as part of the regular build via a Target dependency in `Engine/Engine.csproj`. + +If you see compilation errors related to resources, you can explicitly create the resource files as follows: + +``` +PS> Set-Location ResGen +PS> dotnet run +``` + +This will create compilable C# binding files in respective `gen` directory, which will then be used during build. + +## Editing `.resx` files + +**Do not edit** `.resx` files from Visual Studio. +It will try to create `.cs` files for you and you will get whole bunch of hard-to-understand errors. + +To edit a resource file, use any **plain text editor**. +A resource file is a simple XML file, and it's easy to edit.