Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning AD0001: Analyzer 'StyleCop.Analyzers.OrderingRules.SA1201ElementsMustAppearInTheCorrectOrder' threw an exception of type 'System.Collections.Generic.KeyNotFoundException' with message 'The given key was not present in the dictionary.'. #3788

Closed
rileymckenna opened this issue Jan 27, 2024 · 1 comment

Comments

@rileymckenna
Copy link

rileymckenna commented Jan 27, 2024

This issue was arising when we added a 'record' struct in a .cs file at the bottom of the class.

CSC : warning AD0001: Analyzer 'StyleCop.Analyzers.OrderingRules.SA1201ElementsMustAppearInTheCorrectOrder' threw an
exception of type 'System.Collections.Generic.KeyNotFoundException' with message 'The given key was not present in the
dictionary.'.

Repro issue:

public class FooClass {

...
public List Value {get; set;}
...

public record BarClass([property: JsonProperty("name") string name]);
}

No other indication was given that this was an issue. It was fixed by moving the record above the constructor of the Foo class.

References: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1201.md

I do not need further assistance; this is merely to assist others if they run into a similar issue.

@sharwell
Copy link
Member

Duplicate of #3270

@sharwell sharwell marked this as a duplicate of #3270 Jan 29, 2024
@sharwell sharwell closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants