Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,7 @@ FakesAssemblies/
*.opt

##Our project binplace location
PSScriptAnalyzer/
PSScriptAnalyzer/

## generated resource files
gen/
2 changes: 1 addition & 1 deletion Engine/Commands/GetScriptAnalyzerRuleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected override void ProcessRecord()
IEnumerable<IRule> rules = ScriptAnalyzer.Instance.GetRule(modNames, name);
if (rules == null)
{
WriteObject(string.Format(CultureInfo.CurrentCulture, Strings.RulesNotFound));
WriteObject(string.Format(CultureInfo.CurrentCulture, EngineStrings.RulesNotFound));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Engine/Commands/InvokeFormatterCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions Engine/Commands/InvokeScriptAnalyzerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -363,7 +363,7 @@ protected override void ProcessRecord()
this.WriteVerbose(
String.Format(
CultureInfo.CurrentCulture,
Strings.ModuleDepHandlerTempLocation,
EngineStrings.ModuleDepHandlerTempLocation,
moduleHandler.TempModulePath));
ProcessInput();
}
Expand Down
4 changes: 2 additions & 2 deletions Engine/EditableText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private void ValidateTextEditExtent(TextEdit textEdit)
{
throw new ArgumentException(String.Format(
CultureInfo.CurrentCulture,
Strings.EditableTextRangeIsNotContained));
EngineStrings.EditableTextRangeIsNotContained));
}
}

Expand Down Expand Up @@ -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));
}

Expand Down
8 changes: 7 additions & 1 deletion Engine/Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace> <!-- Namespace needs to match Assembly name for ressource binding -->
</PropertyGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="dotnet run" WorkingDirectory="$(ProjectDir)\..\ResGen" />
</Target>

<ItemGroup>
<PackageReference Include="System.Management.Automation" Version="6.0.0-alpha13" />
</ItemGroup>
Expand All @@ -34,7 +38,8 @@
<Compile Remove="Commands\GetScriptAnalyzerLoggerCommand.cs" />
</ItemGroup>

<ItemGroup>
<!--
<ItemGroup>
<Compile Update="Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand All @@ -48,6 +53,7 @@
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
-->

<PropertyGroup Condition=" '$(Configuration)' == 'PSV3Release' ">
<DefineConstants>$(DefineConstants);PSV3;PSV5</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion Engine/Generic/ConfigurableRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion Engine/Generic/ConfigurableRulePropertyAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 18 additions & 18 deletions Engine/Generic/RuleSuppression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -234,22 +234,22 @@ 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;

case "target":
if (!String.IsNullOrWhiteSpace(Target))
{
Error = String.Format(Strings.NamedAndPositionalArgumentsConflictError, name);
Error = String.Format(EngineStrings.NamedAndPositionalArgumentsConflictError, name);
}

Target = (name.Argument as StringConstantExpressionAst).Value;
Expand All @@ -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;
Expand All @@ -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;
}
}

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -387,13 +387,13 @@ public static List<RuleSuppression> GetSuppressions(IEnumerable<AttributeAst> 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);
Expand Down
14 changes: 7 additions & 7 deletions Engine/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,13 +1467,13 @@ public Tuple<List<SuppressedRecord>, List<DiagnosticRecord>> 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));
Expand Down Expand Up @@ -3739,7 +3739,7 @@ public void AddVertex(T vertex)
{
throw new ArgumentException(
String.Format(
Strings.DigraphVertexAlreadyExists,
EngineStrings.DigraphVertexAlreadyExists,
vertex),
"vertex");
}
Expand All @@ -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()));
}
Expand Down Expand Up @@ -3840,7 +3840,7 @@ private void ValidateVertexPresence(T vertex)
{
throw new ArgumentOutOfRangeException(
String.Format(
Strings.DigraphVertexDoesNotExists,
EngineStrings.DigraphVertexDoesNotExists,
vertex.ToString()),
"vertex");
}
Expand Down
10 changes: 5 additions & 5 deletions Engine/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -73,15 +73,15 @@ 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));
}

newColumn += columnDelta;
if (newColumn < 1)
{
throw new ArgumentException(
String.Format(CultureInfo.CurrentCulture, Strings.PositionColumnLessThanOne),
String.Format(CultureInfo.CurrentCulture, EngineStrings.PositionColumnLessThanOne),
nameof(columnDelta));
}

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Engine/Range.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -109,7 +109,7 @@ private void ValidatePositions()
{
throw new ArgumentException(String.Format(
CultureInfo.CurrentCulture,
Strings.RangeStartPosGreaterThanEndPos));
EngineStrings.RangeStartPosGreaterThanEndPos));
}
}
}
Expand Down
Loading