HR fails when requesting an intermediate empty update
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**: 9.0.302 and 10.0.100-preview.6.25358.103
**Steps to Reproduce**:
1. Install uno templates: `dotnet new install Uno.Templates`
2. Create a new blank app `dotnet new unoapp -o HRwithNoChangesBug -platforms "desktop"`
3. Open the solution in Visual Studio
4. Start the app (with debugger attached)
5. Edit `MainPage.xaml` to add a `ToggleButton`on line 11:
```xml
```
6. Save file and request hot-reload (alt+F10) _(note: I disabled the "Apply Hot Reload on File Save")_
==> Observe in the "Hot Reload" output "Code changes were successfully applied."
7. Without editing any file, request again an hot-reload (alt+F10)
==> Observe in the "Hot Reload" output "No code changes were found."
8. Add a second `ToggleButton` in the `MainPage.xaml` file, right above the previous one
```xml
```
9. Save file and request hot-reload (alt+F10)
```
16:34:50.66 [Error] Exception while emitting update: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.CodeAnalysis.Emit.DefinitionMap.GetPreviousMethodHandle(IMethodSymbolInternal oldMethod, IMethodSymbolInternal& peMethod)
at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.g__getDeletedMethodDefs|83_1(ITypeDefinition typeDef, <>c__DisplayClass83_0&)
at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.g__recurse|83_0(ITypeDefinition typeDef, <>c__DisplayClass83_0&)
at Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter.CreateDeletedMethodsDefs(EmitContext context, SymbolChanges changes)
at Microsoft.CodeAnalysis.Compilation.SerializeToDeltaStreams(CommonPEModuleBuilder moduleBeingBuilt, DefinitionMap definitionMap, SymbolChanges changes, Stream metadataStream, Stream ilStream, Stream pdbStream, ArrayBuilder`1 updatedMethods, ArrayBuilder`1 changedTypes, DiagnosticBag diagnostics, Func`2 testSymWriterFactory, String pdbFilePath, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.CSharp.Emit.EmitHelpers.EmitDifference(CSharpCompilation compilation, EmitBaseline baseline, IEnumerable`1 edits, Func`2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, CompilationTestData testData, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.Compilation.EmitDifference(EmitBaseline baseline, IEnumerable`1 edits, Func`2 isAddedSymbol, Stream metadataStream, Stream ilStream, Stream pdbStream, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.EditAndContinue.EditSession.EmitSolutionUpdateAsync(Solution solution, ActiveStatementSpanProvider solutionActiveStatementSpanProvider, UpdateId updateId, CancellationToken cancellationToken)
16:34:50.66 [Error] C:\Src\Repro\HRwithNoChangesBug\HRwithNoChangesBug\HRwithNoChangesBug.sln (line 1): error ENC1002: Cannot apply changes -- unexpected error: 'Object reference not set to an instance of an object.'
16:34:50.66 Invalid changes were found. Please refer to the Error List window to fix those issues.
```
**Diagnostic Id**:
`error ENC1002: Cannot apply changes -- unexpected error: 'Object reference not set to an instance of an object.'`
**Expected Behavior**:
Able to hot-reload changes.
**Actual Behavior**:
Fails as long as you requested an empty hot-reload (step 7). **If you skip step 7, the hot-reload will work properly.**
Contributor guide
Assessment
This issue has not been assessed yet.