-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
HotReload crashes with "An item with the same key has already been added" #68335
Comments
@Youssef1313 next time you hit it, can you capture a dump and share it (privately on Discord is fine), or even just switch your debug frame to the I tried to create a couple of failing tests in davidwengier@f15cf98 but sadly they both pass. Ordering of the changes in the file don't seem to matter, we still produce the right edits, and emit works fine. I think you must be hitting a specific case where we don't produce edits that we expect in emit. |
Hey @davidwengier can you point me at how I create the dump you requested? |
The issue seems to be that when calculting changes for MainPage_Bindings (which is a nested class within MainPage), the MainPage type is added to the dictionary of changed types. Then on the next iterationg, when the MainPage edit is being processed, it throws the exception because MainPage is already in the changes dictionary |
Thanks @nickrandolph! I see you have If you've caught the exception under the debugger in VS, the easiest way to create a dump is from the Debug menu, "Save Dump As...". |
@davidwengier fwiw, I'm suspecting the dictionary is trying to use reference equality. It's created using the parameterless constructor where it should have been supplied Edit: Wrong guess, still a good idea to use SymbolEqualityComparer.Default though. Edit 2: We first add MainPage_Bindings (and its containing types including MainPage) Then on the next edit which is replacing MainPage, we add it without checking whether it's already there. The fix is not a simple ContainsKey, it should be something like |
@Youssef1313 will share the dump with you. Let me know if you need anthing more |
The issue is that FYI @tmat in case you had any thoughts about appropriate usage here :) |
I can try again but I think the issue exists even if we remove the attribute off the nested type |
The order of edits produced is also vital. Even with the attribute on both types, if the compiler sees the edit for the containing type first, then things work. But the good news is I got a repro in a failing test |
PR opened. FYI, it's a long weeked in the US so I've no idea if anyone will be around to look at it for a couple of days. |
@davidwengier is there a way that I can test this fix using the packages generated by the CI? I've tried referencing the packages from my test app but it seems that VS just defaults to using the version packaged with VS. |
You should be able to clone my fork, switch to the branch, and run |
I don't have a minimal repro yet, but:
roslyn/src/Compilers/Core/Portable/Emit/EditAndContinue/SymbolChanges.cs
Line 497 in 3acd33d
The case involves nested classes, so I'm wondering if it's related to this:
roslyn/src/Compilers/Core/Portable/Emit/EditAndContinue/SymbolChanges.cs
Line 467 in 3acd33d
where the deletion of the method will add containing types, then we get another change for the same type.
The text was updated successfully, but these errors were encountered: