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

[EnC] Deleting partial definition that doesn't have an implementation fails assertion #77340

Closed
tmat opened this issue Feb 26, 2025 · 1 comment · Fixed by #77735
Closed

[EnC] Deleting partial definition that doesn't have an implementation fails assertion #77340

tmat opened this issue Feb 26, 2025 · 1 comment · Fixed by #77735
Assignees

Comments

@tmat
Copy link
Member

tmat commented Feb 26, 2025

Repro:

Make an edit like so:

partial class C
{
    public void InitializeComponent()
    {
        OnInitializeCompleted();
    }

    partial void OnInitializeCompleted();
}
partial class C
{
    public void InitializeComponent()
    {
    }
}
Assertion failed
   at Microsoft.CodeAnalysis.Remote.ThrowingTraceListener.Fail(String message, String detailMessage) in D:\R4\src\Workspaces\Remote\ServiceHub\Host\ThrowingTraceListener.cs:line 14
   at System.Diagnostics.TraceInternal.Fail(String message, String detailMessage)
   at System.Diagnostics.Debug.Fail(String message, String detailMessage)
   at Microsoft.CodeAnalysis.EditAndContinue.SemanticEditInfo.CreateDelete(ISymbol symbol, SymbolKey containingSymbolKey, CancellationToken cancellationToken) in D:\R4\src\Features\Core\Portable\EditAndContinue\SemanticEditInfo.cs:line 86
   at Microsoft.CodeAnalysis.EditAndContinue.AbstractEditAndContinueAnalyzer.<AddDeleteEditsForMemberAndAccessors>g__AddDelete|150_0(ISymbol symbol, <>c__DisplayClass150_0&) in D:\R4\src\Features\Core\Portable\EditAndContinue\AbstractEditAndContinueAnalyzer.cs:line 3725
   at Microsoft.CodeAnalysis.EditAndContinue.AbstractEditAndContinueAnalyzer.AddDeleteEditsForMemberAndAccessors(ArrayBuilder`1 semanticEdits, ISymbol oldSymbol, SymbolKey deletedSymbolContainer, CancellationToken cancellationToken) in D:\R4\src\Features\Core\Portable\EditAndContinue\AbstractEditAndContinueAnalyzer.cs:line 3698
   at Microsoft.CodeAnalysis.EditAndContinue.AbstractEditAndContinueAnalyzer.AnalyzeSemanticsAsync(EditScript`1 editScript, IReadOnlyDictionary`2 editMap, ImmutableArray`1 oldActiveStatements, ImmutableArray`1 newActiveStatementSpans, IReadOnlyList`1 triviaEdits, Project oldProject, Document oldDocument, Document newDocument, SourceText newText, ArrayBuilder`1 diagnostics, Builder newActiveStatements, Builder newExceptionRegions, EditAndContinueCapabilitiesGrantor capabilities, Boolean inBreakState, CancellationToken cancellationToken) in D:\R4\src\Features\Core\Portable\EditAndContinue\AbstractEditAndContinueAnalyzer.cs:line 2833
   at Microsoft.CodeAnalysis.EditAndContinue.AbstractEditAndContinueAnalyzer.AnalyzeDocumentAsync(Project oldProject, AsyncLazy`1 lazyOldActiveStatementMap, Document newDocument, ImmutableArray`1 newActiveStatementSpans, AsyncLazy`1 lazyCapabilities, TraceLog log, CancellationToken cancellationToken) in D:\R4\src\Features\Core\Portable\EditAndContinue\AbstractEditAndContinueAnalyzer.cs:line 643
@jeromelaban
Copy link

jeromelaban commented Feb 26, 2025

@tmat Thanks for the update! This is indeed something that we identified as a possible cause of dotnet/maui#27612. Keeping the partial makes the deltas to be generated correctly.

This particular error (and stack trace) happened in other cases, though, but we weren't able to reproduce the issue reliably in a generic context in order to open an issue. A null reference happened at that location:

return (MethodDefinitionHandle)MetadataTokens.EntityHandle(peMethod.MetadataToken);

One of the lead we got was related to possible links between cross-targeting and desynchronized based binaries, based on this VS feedback issue.

The scenario looks like this, in VS 17.13:

  • In a MAUI solution with windows, iOS and Android, do a rebuild, generating version 1 of all the TFM assemblies
  • Debug the app in net9.0-windows (using the debugger green arrow button)
  • Make a significant code change then hot reload
  • Stop the app
  • Debug the app again (using the debugger green arrow button), which will generate version 2 of net9.0-windows, but keeps the original version 1 of net9.0-ios and net9.0-android
  • Make another change that can generate a delta update that is inconsistent between version 1 and the version 2 code changes, where the HRWorkspace tries to generate deltas using invalid base binaries.

We think the problem that the issue happens when using the SingleTargetBuildForStartupProjects VS capability. We got to work around that occurrence issue by deleting the assemblies in the IntermediatePath folders (unoplatform/uno#19463), but that's mostly a workaround.

If you're interested, we could provide a more specialized repro using public bits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants