Title: Collection was modified; enumeration operation may not execute when running Invoke-ScriptAnalyzer · Issue #1516 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: Collection was modified; enumeration operation may not execute when running Invoke-ScriptAnalyzer · Issue #1516 · PowerShell/PSScriptAnalyzer
X Title: Collection was modified; enumeration operation may not execute when running Invoke-ScriptAnalyzer · Issue #1516 · PowerShell/PSScriptAnalyzer
Description: Before submitting a bug report: Perform a quick search for existing issues to check if this bug has already been reported This may be related to: PSUseToExportFieldsInManifest throw System.InvalidOperationException: Collection was modifi...
Open Graph Description: Before submitting a bug report: Perform a quick search for existing issues to check if this bug has already been reported This may be related to: PSUseToExportFieldsInManifest throw System.InvalidO...
X Description: Before submitting a bug report: Perform a quick search for existing issues to check if this bug has already been reported This may be related to: PSUseToExportFieldsInManifest throw System.InvalidO...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/1516
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Collection was modified; enumeration operation may not execute when running Invoke-ScriptAnalyzer","articleBody":"Before submitting a bug report:\r\n\r\n- Perform a quick search for existing issues to check if this bug has already been reported\r\n\r\nThis may be related to:\r\n[PSUseToExportFieldsInManifest throw System.InvalidOperationException: Collection was modified; enumeration operation may not execute #902](https://github.com/PowerShell/PSScriptAnalyzer/issues/902)\r\n\r\nSteps to reproduce\r\n------------------\r\n[PSScriptAnalyzer - Collection was modified.zip](https://github.com/PowerShell/PSScriptAnalyzer/files/4705754/PSScriptAnalyzer.-.Collection.was.modified.zip)\r\n\r\n1. Unzip the above into a folder.\r\n2. Open that folder in PowerShell 7.\r\n3. Execute: `$x = .\\Test.ps1 -Run 10 -SAVersion '1.19.0'`\r\n4. The results will contain entries with `Collection was modified; enumeration operation may not execute` exceptions. If run several times different files will have these exceptions.\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nNo `Collection was modified; enumeration operation may not execute.` issues.\r\n\r\nIf I change to a previous version of the module the issue goes away:\r\n1. Unzip the above into a folder.\r\n2. Open that folder in PowerShell 7.\r\n3. Execute: `$x = .\\Test.ps1 -Run 10 -SAVersion '1.18.3'`\r\n4. The results will contain NO `Collection was modified; enumeration operation may not execute` exceptions. If run several times there will never be any such exceptions.\r\n\r\nActual behavior\r\n---------------\r\n\r\nSeveral issues are returned. If run multiple times different files show the issues. Sample error message:\r\n\r\n```PowerShell\r\nInvoke-ScriptAnalyzer: C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\\Test.ps1:29\r\nLine |\r\n 29 | … $issues = Invoke-ScriptAnalyzer -Path $file -Settings $settings `\r\n | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n | Collection was modified; enumeration operation may not execute.\r\n\r\n```\r\n\r\nIf an unexpected error was thrown then please report the full error details using e.g. `$error[0] | Select-Object *`\r\n\r\n```none\r\nPSMessageDetails :\r\nException : System.InvalidOperationException: Collection was modified; enumeration operation may not execute.\r\n at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()\r\n at System.Management.Automation.CommandInfo.get_Parameters()\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseCorrectCasing.AnalyzeScript(Ast ast, String fileName)+MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.\u003c>c__DisplayClass82_1.\u003cAnalyzeSyntaxTree>b__2()\r\nTargetObject : C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\\Functions\\Private\\Get-HFGitStatus.ps1\r\nCategoryInfo : InvalidOperation: (C:\\Data\\PowerShell\\…Get-HFGitStatus.ps1:String) [Invoke-ScriptAnalyzer], InvalidOperationException\r\nFullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand\r\nErrorDetails :\r\nInvocationInfo : System.Management.Automation.InvocationInfo\r\nScriptStackTrace : at \u003cScriptBlock>, C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\\Test.ps1: line 29\r\n at \u003cScriptBlock>, \u003cNo file>: line 1\r\nPipelineIterationInfo : {0, 1}\r\n```\r\n\r\n```none\r\n> Get-Error -InputObject $x[0].ErrorRecord\r\n\r\nException :\r\n Type : System.InvalidOperationException\r\n TargetSite :\r\n Name : ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion\r\n DeclaringType : System.ThrowHelper, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e\r\n MemberType : Method\r\n Module : System.Private.CoreLib.dll\r\n StackTrace :\r\n at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()\r\n at System.Management.Automation.CommandInfo.get_Parameters()\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseCorrectCasing.AnalyzeScript(Ast ast, String fileName)+MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.\u003c>c__DisplayClass82_1.\u003cAnalyzeSyntaxTree>b__2()\r\n Message : Collection was modified; enumeration operation may not execute.\r\n Source : System.Private.CoreLib\r\n HResult : -2146233079\r\nTargetObject : C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\\Functions\\Private\\Get-HFGitStatus.ps1\r\nCategoryInfo : InvalidOperation: (C:\\Data\\PowerShell\\…Get-HFGitStatus.ps1:String) [Invoke-ScriptAnalyzer], InvalidOperationException\r\nFullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand\r\nInvocationInfo :\r\n MyCommand : Invoke-ScriptAnalyzer\r\n ScriptLineNumber : 29\r\n OffsetInLine : 19\r\n HistoryId : 12\r\n ScriptName : C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\\Test.ps1\r\n Line : $issues = Invoke-ScriptAnalyzer -Path $file -Settings $settings `\r\n\r\n PositionMessage : At C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\\Test.ps1:29 char:19\r\n + … $issues = Invoke-ScriptAnalyzer -Path $file -Settings $settings `\r\n + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n PSScriptRoot : C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\r\n PSCommandPath : C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\\Test.ps1\r\n InvocationName : Invoke-ScriptAnalyzer\r\n CommandOrigin : Internal\r\nScriptStackTrace : at \u003cScriptBlock>, C:\\Data\\PowerShell\\Miscellaneous\\Issues\\PSScriptAnalyzer - Collection was modified\\Test.ps1: line 29\r\n at \u003cScriptBlock>, \u003cNo file>: line 1\r\nPipelineIterationInfo :\r\n\r\n\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- Provide the output of the following 2 commands -->\r\n\r\n```none\r\n> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 7.0.1\r\nPSEdition Core\r\nGitCommitId 7.0.1\r\nOS Microsoft Windows 10.0.18363\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n\r\n> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }\r\n\r\n1.19.0\r\n1.18.3\r\n1.18.2\r\n1.18.1\r\n1.18.0\r\n1.17.1\r\n```\r\n","author":{"url":"https://github.com/mrboring","@type":"Person","name":"mrboring"},"datePublished":"2020-05-30T14:47:22Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/1516"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d2a5222b-bd34-344a-10ef-89cba7aa3291 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C8C2:A74EC:6255A:87968:6AFCE825 |
| html-safe-nonce | d87f321c9e420e540814e79fda7c0d9fcefe113222f94c08736464629a90ac1b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEMyOkE3NEVDOjYyNTVBOjg3OTY4OjZBRkNFODI1IiwidmlzaXRvcl9pZCI6IjI0MjM5NjE1NTY2MTA3NzA5ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7484a013af18f9cb50f0a2ac429b1f5c9d64f46bb6838f7a62d3373d4f2e544a |
| hovercard-subject-tag | issue:627749350 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/1516/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f82d38bd0d459b5984396f63939ce43af657e7a101e1dfff58627bf27eb9878b/PowerShell/PSScriptAnalyzer/issues/1516 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f82d38bd0d459b5984396f63939ce43af657e7a101e1dfff58627bf27eb9878b/PowerShell/PSScriptAnalyzer/issues/1516 |
| og:image:alt | Before submitting a bug report: Perform a quick search for existing issues to check if this bug has already been reported This may be related to: PSUseToExportFieldsInManifest throw System.InvalidO... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mrboring |
| hostname | github.com |
| expected-hostname | github.com |
| None | 99aede4c5f55ec5cf06666a8c9e03ebf9f85f7231223e7f1c38c16e5504835b3 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 33149177 |
| octolytics-dimension-repository_nwo | PowerShell/PSScriptAnalyzer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33149177 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PSScriptAnalyzer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ecfd63ca125ec74b42f74eeb158b3fa081c8c497 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width