Enabling PSUseCorrectCasing causes error while processing code that doesn't violate it
@bergmeister đang làm issue này rồi.
Từ ngày 1/2/2023.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Steps to reproduce
'@{ Rules = @{ PSUseCorrectCasing = @{ Enable = $true } } }' > rules.psd1
Invoke-ScriptAnalyzer -Settings rules.psd1 -ScriptDefinition 'Update-VisualStudioSolutionNuGetPackages'
Update: It turned out that our Update-VisualStudioSolutionNuGetPackages cmdlet actually had a problem (incorrectly parameterized analyzer suppression), although it's important to note that that cmdlet was not subject to code analysis when the problem arose (but the same runtime error appears too when executing that cmdlet), only the script that was calling it.
Expected behavior
No output.
Actual behavior
The following error details in both Windows PowerShell and PowerShell Core:
writeErrorStream : True
PSMessageDetails :
Exception : System.Management.Automation.MethodException: Cannot find an overload for ".ctor" and the argument count: "1".
at System.Management.Automation.Language.Compiler.GetAttribute(AttributeAst attributeAst)
at System.Management.Automation.Language.ScriptBlockAst.<System-Management-Automation-Language-IParameterMetadataProvider-GetScriptBlockAttributes>d__68.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at System.Management.Automation.CompiledScriptBlockData.InitializeMetadata()
at System.Management.Automation.CompiledScriptBlockData.get_CmdletBindingAttribute()
at System.Management.Automation.CommandMetadata.Init(ScriptBlock scriptBlock, String name, Boolean shouldGenerateCommonParameters)
at System.Management.Automation.CommandMetadata..ctor(CommandInfo commandInfo, Boolean shouldGenerateCommonParameters)
at System.Management.Automation.CommandInfo.get_Parameters()
at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseCorrectCasing.<AnalyzeScript>d__0.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.<>c__DisplayClass85_1.<AnalyzeSyntaxTree>b__2()
TargetObject :
CategoryInfo : InvalidOperation: (:) [Invoke-ScriptAnalyzer], MethodException
FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
Environment data
Windows PowerShell
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.19041.2364
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.2364
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.21.0
PowerShell Core
> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.1
PSEdition Core
GitCommitId 7.3.1
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.21.0
- Ngôn ngữ chính
- C#
- Star
- 2.2k
- Fork
- 415
- Merge trung bình
- 13 giờ 1 phút
- Pull request đã merge (30 ngày)
- 2
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PowerShell/PSScriptAnalyzer
-
Up-for-Grabs
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 bình luận ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
PowerShell/PSScriptAnalyzer#2210 ·
Tất cả issue của PowerShell/PSScriptAnalyzer
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nightscout/nocturne#1379 ·
-
release-notes in .NET 11 RC2 Đang mởpriority-0
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
StackExchange/StackExchange.Redis#3249 ·
-
[Feat] 조합 영역 구분선 개선 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100