OYIon / LiveSharp

Public repository for the LiveSharp project
96 stars 4 forks source link

Adding Property Stops Updates #104

Closed warappa closed 1 year ago

warappa commented 3 years ago

Problem

If I add a property to my razor file the updates breaks.

Repo

https://github.com/warappa/RepoLiveSharpUpdateFailsWithMatBlazor/tree/add-property-breaks-updates Branch: add-property-breaks-updates

Prerequisites

Steps

  1. Deleted C:\Users\<username>\.nuget\packages\livesharp\1.6.33
  2. Deleted %Temp%\LiveSharp
  3. Ran git clean -fdx on checked out repo
  4. Opened in VS 2019 16.8.1
  5. Rebuilt whole Solution
  6. Set RepoLiveSharpUpdateFailsWithMatBlazor.Server as Startup Project
  7. Start LiveSharp Server
  8. Start project with CTRL+F5
  9. In Index.razor under AssemblyString insert public string Test { get; set; } and save
  10. Exception is shown in output of LiveSharp.Server (see below)
  11. No further change is reflected in the browser app

Without this tiny change i.e. duplicating SurveyPrompt or removing SurveyPrompt works flawlessly.

22:00:03.840: Starting job: Dry run for RepoLiveSharpUpdateFailsWithMatBlazor.Client
server: 1.6.7.0
nuget: 1.6.33
Hosting environment: Production
Content root path: C:\Users\spoil\.nuget\packages\livesharp\1.6.33\build\Workspace
Now listening on: http://127.0.0.1:56592
Application started. Press Ctrl+C to shut down.
22:00:08.138: Ended job: Dry run for RepoLiveSharpUpdateFailsWithMatBlazor.Client (4297)
22:00:23.344: Starting job: Handling Razor update: Pages\Index.razor
22:00:23.351: Job failed: Handling Razor update: Pages\Index.razor
System.IO.IOException: The process cannot access the file 'E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\Client\Pages\Index.razor' because it is being used by another process.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at LiveSharp.DefaultRazorProjectItem.Read()
   at Microsoft.AspNetCore.Razor.Language.RazorSourceDocument.ReadFrom(RazorProjectItem projectItem)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.CreateCodeDocumentCore(RazorProjectItem projectItem, Action`1 configureParser, Action`1 configureCodeGeneration)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.CreateCodeDocumentCore(RazorProjectItem projectItem)
   at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem)
   at LiveSharp.RazorBuildEngine.GetGeneratedCode(TextDocument document)
   at LiveSharp.RazorHandler.GetGeneratedCode(TextDocument document)
   at LiveSharp.LiveSharpWorkspace.<>c__DisplayClass28_0.<RazorFileChanged>b__0()
   at LiveSharp.Infrastructure.JobQueue.<>c__DisplayClass7_0.<<AddAsyncJob>b__0>d.MoveNext()
22:00:25.416: Starting job: Handling Razor update: Pages\Index.razor
22:00:25.594: Updating obj\Debug\net5.0\Razor\Pages\Index.razor.g.cs
22:00:25.683: Ended job: Handling Razor update: Pages\Index.razor (2336)
22:00:25.705: Received C# update
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '/livesharp'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 27260.2601ms 101
22:00:26.325: warning: ReflectionTypeLoadException Microsoft.JSInterop.WebAssembly, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60: Unable to load one or more of the requested types.
Generic method or method in generic class is internal call, PInvoke, or is defined in a COM Import class.
Could not load type 'WebAssembly.JSInterop.JSCallInfo' from assembly 'Microsoft.JSInterop.WebAssembly, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.
22:00:26.358: Received update for property RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.Test
22:00:26.360: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.<Test>k__BackingField
22:00:26.362: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__13_0
22:00:26.363: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__13_1
22:00:26.365: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<OnInitializedAsync>d__13.<>1__state
22:00:26.366: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<OnInitializedAsync>d__13.<>t__builder
22:00:26.368: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<OnInitializedAsync>d__13.<>4__this
22:00:26.372: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<OnInitializedAsync>d__13.<assemblies>5__1
22:00:26.373: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<OnInitializedAsync>d__13.<assemblyInfos>5__2
22:00:26.374: Received update for method Index.get_Test
22:00:26.376: Received update for method Index.set_Test
22:00:26.377: Received update for method Index.OnInitializedAsync
22:00:26.378: Received update for method Index+<>c.<OnInitializedAsync>b__13_0
22:00:26.380: Received update for method Index+<>c.<OnInitializedAsync>b__13_1
22:00:26.381: Received update for method Index+<OnInitializedAsync>d__13..ctor
22:00:26.382: Received update for method Index+<OnInitializedAsync>d__13.MoveNext
22:00:26.383: Received update for method Index+<OnInitializedAsync>d__13.SetStateMachine

Extra

If you use the steps above and instead of adding Test property you replace the whole page with the following content, you get an IL Compilation failed error:

Content

@page "/"

<h1>Hello, world!</h1>

Welcome to your new app.

<button @onclick="@(e => Load())">Load Infos</button>

<SurveyPrompt Title="How is Blazor working for you?" />

<textarea style="width: 900px;height: 300px" value="@TypesString"></textarea>
<textarea style="width: 900px;height: 300px" value="@AssemblyString"></textarea>

@code {

    public string AssemblyString { get; set; }
    public string TypesString { get; set; }

    protected override async Task OnInitializedAsync()
    {
        Load();
    }

    public void Load()
    {
        var assemblies = AppDomain.CurrentDomain.GetAssemblies()
            .OrderBy(x => x.FullName)
            .ToArray();
        var assemblyInfos = assemblies

            .Select(x => $"{x.FullName}")
            .ToArray();

        AssemblyString = string.Join("\r\n", assemblyInfos);

        var types = typeof(RepoLiveSharpUpdateFailsWithMatBlazor.Client.Program).Assembly
            .GetExportedTypes()
            .Select(x => x.FullName)
            .OrderBy(x => x)
            .ToArray();

        TypesString =$"{DateTime.UtcNow}\r\n{string.Join("\r\n", types)}";
    }
}

Exception

22:17:10.446: Starting job: Dry run for RepoLiveSharpUpdateFailsWithMatBlazor.Client
server: 1.6.7.0
nuget: 1.6.33
Hosting environment: Production
Content root path: C:\Users\spoil\.nuget\packages\livesharp\1.6.33\build\Workspace
Now listening on: http://127.0.0.1:57903
Application started. Press Ctrl+C to shut down.
22:17:14.813: Ended job: Dry run for RepoLiveSharpUpdateFailsWithMatBlazor.Client (4366)
22:17:26.976: Starting job: Handling Razor update: Pages\Index.razor
22:17:27.227: Updating obj\Debug\net5.0\Razor\Pages\Index.razor.g.cs
22:17:27.333: Ended job: Handling Razor update: Pages\Index.razor (355)
22:17:27.361: Received C# update
22:17:27.991: Received C# update
22:17:27.999: Received update for property RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.TypesString
22:17:28.000: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.<TypesString>k__BackingField
22:17:28.001: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__10_0
22:17:28.002: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__10_1
22:17:28.002: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__10_2
22:17:28.002: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__10_3
22:17:28.003: Received update for method Index.BuildRenderTree
22:17:28.004: Received update for method Index.get_TypesString
22:17:28.004: Received update for method Index.set_TypesString
22:17:28.005: Received update for method Index.Load
22:17:28.005: Received update for method Index.<BuildRenderTree>b__0_0
22:17:28.005: Received update for method Index+<OnInitializedAsync>d__9.MoveNext
22:17:28.006: Received update for method Index+<>c.<Load>b__10_0
22:17:28.006: Received update for method Index+<>c.<Load>b__10_1
22:17:28.007: Received update for method Index+<>c.<Load>b__10_2
22:17:28.007: Received update for method Index+<>c.<Load>b__10_3
22:17:28.059: warning: ReflectionTypeLoadException Microsoft.JSInterop.WebAssembly, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60: Unable to load one or more of the requested types.
Generic method or method in generic class is internal call, PInvoke, or is defined in a COM Import class.
Could not load type 'WebAssembly.JSInterop.JSCallInfo' from assembly 'Microsoft.JSInterop.WebAssembly, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.
22:17:28.084: Received update for property RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.TypesString
22:17:28.085: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.<TypesString>k__BackingField
22:17:28.086: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__10_0
22:17:28.086: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__10_1
22:17:28.087: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__10_2
22:17:28.087: Received update for field RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<>9__10_3
22:17:28.091: Received update for method Index.BuildRenderTree
22:17:28.092: Received update for method Index.get_TypesString
22:17:28.093: Received update for method Index.set_TypesString
22:17:28.094: Received update for method Index.Load
22:17:28.094: Received update for method Index.<BuildRenderTree>b__0_0
22:17:28.095: Received update for method Index+<OnInitializedAsync>d__9.MoveNext
22:17:28.095: Received update for method Index+<>c.<Load>b__10_0
22:17:28.096: Received update for method Index+<>c.<Load>b__10_1
22:17:28.096: Received update for method Index+<>c.<Load>b__10_2
22:17:28.096: Received update for method Index+<>c.<Load>b__10_3
22:17:28.196: error: IL Compilation failed:
<Method Name="BuildRenderTree" MethodIdentifier="RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index BuildRenderTree Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder" DeclaringType="RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index" DebugLevel="0" MaxStackSize="7" IsStatic="false" ReturnType="8" IsConstructor="false" IsPropertyMethod="false">
  <Parameters>
    <Parameter Name="__builder" Type="6" />
  </Parameters>
  <Members>
    <Member Token="167772199" ContainingType="6" Name="AddMarkupContent" ReturnType="8" MemberType="Method" ParameterTypes="7,0" />
    <Member Token="167772196" ContainingType="6" Name="OpenElement" ReturnType="8" MemberType="Method" ParameterTypes="7,0" />
    <Member Token="167772203" MemberType="Field" ContainingType="10" Type="9" Name="Factory" />
    <Member Token="100663329" ContainingType="12" Name="&lt;BuildRenderTree&gt;b__0_0" ReturnType="8" MemberType="Method" ParameterTypes="11" />
    <Member Token="167772214" ContainingType="15" Name=".ctor" ReturnType="8" MemberType="Method" ParameterTypes="13,14" />
    <Member Token="721420298" ContainingType="9" Name="Create" MemberType="Method" ReturnType="16" ParameterTypes="13,15" GenericArguments="11" />
    <Member Token="721420294" ContainingType="6" Name="AddAttribute" MemberType="Method" ReturnType="8" ParameterTypes="7,0,16" GenericArguments="11" />
    <Member Token="167772207" ContainingType="6" Name="AddContent" ReturnType="8" MemberType="Method" ParameterTypes="7,0" />
    <Member Token="167772198" ContainingType="6" Name="CloseElement" ReturnType="8" MemberType="Method" ParameterTypes="" />
    <Member Token="721420299" ContainingType="6" Name="OpenComponent" MemberType="Method" ReturnType="8" ParameterTypes="7" GenericArguments="17" />
    <Member Token="167772197" ContainingType="6" Name="AddAttribute" ReturnType="8" MemberType="Method" ParameterTypes="7,0,0" />
    <Member Token="167772194" ContainingType="6" Name="CloseComponent" ReturnType="8" MemberType="Method" ParameterTypes="" />
    <Member Token="100663324" ContainingType="12" Name="get_TypesString" ReturnType="0" MemberType="Method" ParameterTypes="" />
    <Member Token="100663322" ContainingType="12" Name="get_AssemblyString" ReturnType="0" MemberType="Method" ParameterTypes="" />
  </Members>
  <Locals />
  <ExceptionHandlers />
  <Strings>
    <S Id="0">&lt;h1&gt;Hello, world!&lt;/h1&gt;

Welcome to your new app.

</S>
    <S Id="1">button</S>
    <S Id="2">onclick</S>
    <S Id="3">Load Infos</S>
    <S Id="4">

</S>
    <S Id="5">Title</S>
    <S Id="6">How is Blazor working for you?</S>
    <S Id="7">textarea</S>
    <S Id="8">style</S>
    <S Id="9">width: 900px;height: 300px</S>
    <S Id="10">value</S>
    <S Id="11">
</S>
  </Strings>
  <IL>nop
ldarg.1
ldc.i4.0
ldstr s0
callvirt t167772199 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddMarkupContent(System.Int32,System.String)
nop
ldarg.1
ldc.i4.1
ldstr s1
callvirt t167772196 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::OpenElement(System.Int32,System.String)
nop
ldarg.1
ldc.i4.2
ldstr s2
ldsfld t167772203 //Microsoft.AspNetCore.Components.EventCallbackFactory Microsoft.AspNetCore.Components.EventCallback::Factory
ldarg.0
ldarg.0
ldftn t100663329 //System.Void RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index::&lt;BuildRenderTree&gt;b__0_0(Microsoft.AspNetCore.Components.Web.MouseEventArgs)
newobj t167772214 //System.Void System.Action`1&lt;Microsoft.AspNetCore.Components.Web.MouseEventArgs&gt;::.ctor(System.Object,System.IntPtr)
callvirt t721420298 //Microsoft.AspNetCore.Components.EventCallback`1&lt;!!0&gt; Microsoft.AspNetCore.Components.EventCallbackFactory::Create&lt;Microsoft.AspNetCore.Components.Web.MouseEventArgs&gt;(System.Object,System.Action`1&lt;!!0&gt;)
callvirt t721420294 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddAttribute&lt;Microsoft.AspNetCore.Components.Web.MouseEventArgs&gt;(System.Int32,System.String,Microsoft.AspNetCore.Components.EventCallback`1&lt;!!0&gt;)
nop
ldarg.1
ldc.i4.3
ldstr s3
callvirt t167772207 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddContent(System.Int32,System.String)
nop
ldarg.1
callvirt t167772198 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::CloseElement()
nop
ldarg.1
ldc.i4.4
ldstr s4
callvirt t167772199 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddMarkupContent(System.Int32,System.String)
nop
ldarg.1
ldc.i4.5
callvirt t721420299 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::OpenComponent&lt;RepoLiveSharpUpdateFailsWithMatBlazor.Client.Shared.SurveyPrompt&gt;(System.Int32)
nop
ldarg.1
ldc.i4.6
ldstr s5
ldstr s6
callvirt t167772197 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddAttribute(System.Int32,System.String,System.String)
nop
ldarg.1
callvirt t167772194 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::CloseComponent()
nop
ldarg.1
ldc.i4.7
ldstr s4
callvirt t167772199 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddMarkupContent(System.Int32,System.String)
nop
ldarg.1
ldc.i4.8
ldstr s7
callvirt t167772196 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::OpenElement(System.Int32,System.String)
nop
ldarg.1
ldc.i4.s 9
ldstr s8
ldstr s9
callvirt t167772197 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddAttribute(System.Int32,System.String,System.String)
nop
ldarg.1
ldc.i4.s 10
ldstr s10
ldarg.0
call t100663324 //System.String RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index::get_TypesString()
callvirt t167772197 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddAttribute(System.Int32,System.String,System.String)
nop
ldarg.1
callvirt t167772198 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::CloseElement()
nop
ldarg.1
ldc.i4.s 11
ldstr s11
callvirt t167772199 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddMarkupContent(System.Int32,System.String)
nop
ldarg.1
ldc.i4.s 12
ldstr s7
callvirt t167772196 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::OpenElement(System.Int32,System.String)
nop
ldarg.1
ldc.i4.s 13
ldstr s8
ldstr s9
callvirt t167772197 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddAttribute(System.Int32,System.String,System.String)
nop
ldarg.1
ldc.i4.s 14
ldstr s10
ldarg.0
call t100663322 //System.String RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index::get_AssemblyString()
callvirt t167772197 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::AddAttribute(System.Int32,System.String,System.String)
nop
ldarg.1
callvirt t167772198 //System.Void Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder::CloseElement()
nop
ret</IL>
</Method>
System.AggregateException: Instruction compilation failed: 68: call v-method: RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index get_TypesString  (No coercion operator is defined between types 'RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index' and 'LiveSharp.Runtime.Virtual.VirtualType0'.)
 ---> System.InvalidOperationException: No coercion operator is defined between types 'RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index' and 'LiveSharp.Runtime.Virtual.VirtualType0'.
   at System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
   at System.Linq.Expressions.Expression.Convert(Expression expression, Type type, MethodInfo method)
   at System.Linq.Expressions.Expression.Convert(Expression expression, Type type)
   at LiveSharp.Runtime.IL.CompilerHelpers.Coerce(Expression expr, Type targetType)
   at LiveSharp.Runtime.IL.IlExpressionCompilerHandlers.CallImpl(InstructionContext ctx, Boolean isVirtualCall)
   at LiveSharp.Runtime.IL.IlExpressionCompilerHandlers.Call(InstructionContext ctx)
   at LiveSharp.Runtime.IL.IlExpressionCompiler.CompileInstruction(InstructionContext instructionContext)
   --- End of inner exception stack trace ---
   at LiveSharp.Runtime.IL.IlExpressionCompiler.CompileInstruction(InstructionContext instructionContext)
   at LiveSharp.Runtime.IL.CompilerContext.Compile(IlInstruction instruction, ImmutableStack`1 stack)
   at LiveSharp.Runtime.IL.CompilerContext.CompileBranch(Int32 instructionIndex)
   at LiveSharp.Runtime.IL.CompilerContext.<CompileInstructions>g__compileBranch|36_0(Int32 index)
   at LiveSharp.Runtime.IL.CompilerContext.CompileInstructions()
   at LiveSharp.Runtime.IL.IlExpressionCompiler.GetDelegate(Boolean enableDebugging, Type delegateType)
   at LiveSharp.Runtime.IL.MethodMetadata.CreateDelegate(Type delegateType)
22:17:28.212: error: IlCompilationException: System.AggregateException: Instruction compilation failed: 68: call v-method: RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index get_TypesString  (No coercion operator is defined between types 'RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index' and 'LiveSharp.Runtime.Virtual.VirtualType0'.)
 ---> System.InvalidOperationException: No coercion operator is defined between types 'RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index' and 'LiveSharp.Runtime.Virtual.VirtualType0'.
   at System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
   at System.Linq.Expressions.Expression.Convert(Expression expression, Type type, MethodInfo method)
   at System.Linq.Expressions.Expression.Convert(Expression expression, Type type)
   at LiveSharp.Runtime.IL.CompilerHelpers.Coerce(Expression expr, Type targetType)
   at LiveSharp.Runtime.IL.IlExpressionCompilerHandlers.CallImpl(InstructionContext ctx, Boolean isVirtualCall)
   at LiveSharp.Runtime.IL.IlExpressionCompilerHandlers.Call(InstructionContext ctx)
   at LiveSharp.Runtime.IL.IlExpressionCompiler.CompileInstruction(InstructionContext instructionContext)
   --- End of inner exception stack trace ---
   at LiveSharp.Runtime.IL.IlExpressionCompiler.CompileInstruction(InstructionContext instructionContext)
   at LiveSharp.Runtime.IL.CompilerContext.Compile(IlInstruction instruction, ImmutableStack`1 stack)
   at LiveSharp.Runtime.IL.CompilerContext.CompileBranch(Int32 instructionIndex)
   at LiveSharp.Runtime.IL.CompilerContext.<CompileInstructions>g__compileBranch|36_0(Int32 index)
   at LiveSharp.Runtime.IL.CompilerContext.CompileInstructions()
   at LiveSharp.Runtime.IL.IlExpressionCompiler.GetDelegate(Boolean enableDebugging, Type delegateType)
   at LiveSharp.Runtime.IL.MethodMetadata.CreateDelegate(Type delegateType)

I think they are releated so I post those 2 issues together.

This issues cause my work on my regular project to be really "difficult" if you understand what I mean :)

ionoy commented 3 years ago

OK, it seems like the issue is fixed. I had to do a pretty major rewrite, which honestly was a long time coming.

Here is a build you can try: LiveSharp.1.6.34.zip

warappa commented 3 years ago

Thanks @ionoy !

My observations:

Reconnect log (Server)

LiveSharp: Found available port: 50539
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
      User profile is available. Using 'C:\Users\spoil\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
LiveSharp: Initializing LiveHost at 50540
LiveSharp: Listening on port 50540 starting
LiveSharp: Listening on port 50540 started
Hosting environment: Production
Content root path: C:\Users\spoil
Now listening on: https://127.0.0.1:50539
Application started. Press Ctrl+C to shut down.

Welcome to LiveSharp!

Documentation https://www.livesharp.net/help/
Live support https://gitter.im/LiveSharp/Lobby (@ionoy)
Server app releases https://github.com/OYIon/LiveSharp/releases
License purchasing https://www.livesharp.net/#licensing
Log files locations are %TEMP%\LiveSharp on Windows and $TMPDIR/LiveSharp on OSX

1) Make sure 'LiveSharp' package is installed in the main project (the one with Program.Main or App.Initialize)
   Also install 'LiveSharp' into other projects that should be hot-reloadable
2) Run the application
   If nothing appears here after application has started, check the debugging Output window for 'livesharp: ' messages

LiveSharp: client connected: 192.168.0.13:56405
LiveSharp: Client joined group 1
LiveSharp: Client joined group 4
LiveSharp: Starting dashboard process with arguments:  /SolutionPath="E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\RepoLiveSharpUpdateFailsWithMatBlazor.sln" /ProjectName="RepoLiveSharpUpdateFailsWithMatBlazor.Server" /ProjectDir="E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\Server" /NuGetPackagePath="C:\Users\spoil\.nuget\packages\livesharp\1.6.36\build" /ServerVersion="1.6.7.0"
17:29:53.530: Transport type: LiveSharp.ServerClient.SocketTransport
17:29:53.539: Connecting to 127.0.0.1:50540
LiveSharp: client connected: 127.0.0.1:56408
17:29:53.544: Connected to 127.0.0.1:50540
LiveSharp: Client joined group 7
17:29:53.557: Dashboard connected to the host
LiveSharp: Client joined group 6
LiveSharp: Client joined group 5
17:29:56.985: Workspace loading finished in 3419ms
17:29:57.050: watcher created at E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\Client\
17:29:57.063: watcher created at E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\Server\
17:29:57.069: Starting job: Dry run for RepoLiveSharpUpdateFailsWithMatBlazor.Server
server: 1.6.7.0
nuget: 1.6.36
Hosting environment: Production
Content root path: C:\Users\spoil\.nuget\packages\livesharp\1.6.36\build\Workspace
Now listening on: http://127.0.0.1:56407
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 OPTIONS https://localhost.livesharp.net:50539/livesharp/negotiate?negotiateVersion=1
info: Microsoft.AspNetCore.Cors.Infrastructure.CorsService[4]
      CORS policy execution successful.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 42.1075ms 204
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 POST https://localhost.livesharp.net:50539/livesharp/negotiate?negotiateVersion=1  0
info: Microsoft.AspNetCore.Cors.Infrastructure.CorsService[4]
      CORS policy execution successful.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint '/livesharp/negotiate'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '/livesharp/negotiate'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished in 21.0867ms 200 application/json
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/1.1 GET https://localhost.livesharp.net:50539/livesharp?id=yRqrsfxE8hEuKNjIxc5qGg
info: Microsoft.AspNetCore.Cors.Infrastructure.CorsService[4]
      CORS policy execution successful.
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint '/livesharp'
LiveSharp: Starting dashboard process with arguments:  /SolutionPath="E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\RepoLiveSharpUpdateFailsWithMatBlazor.sln" /ProjectName="RepoLiveSharpUpdateFailsWithMatBlazor.Client" /ProjectDir="E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\Client" /NuGetPackagePath="C:\Users\spoil\.nuget\packages\livesharp\1.6.36\build" /ServerVersion="1.6.7.0"
LiveSharp: Error: EndReceive failed
System.Net.Sockets.SocketException (10054): Eine vorhandene Verbindung wurde vom Remotehost geschlossen.
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at LiveSharp.Server.Network.LiveHost.EndReceive(IAsyncResult ar) in C:\Projects\LiveSharp\src\LiveSharp.Server.Common\Network\LiveHost.cs:line 85
LiveSharp: client disconnected: 127.0.0.1:56408
17:30:01.115: Transport type: LiveSharp.ServerClient.SocketTransport
17:30:01.121: Connecting to 127.0.0.1:50540
LiveSharp: client connected: 127.0.0.1:56429
17:30:01.127: Connected to 127.0.0.1:50540
LiveSharp: Client joined group 7
LiveSharp: Client joined group 6
17:30:01.139: Dashboard connected to the host
LiveSharp: Client joined group 5
17:30:03.500: Workspace loading finished in 2356ms
17:30:03.561: watcher created at E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\Client\
17:30:03.573: watcher created at E:\Programmieren\RepoLiveSharpUpdateFailsWithMatBlazor\Server\
17:30:03.579: Starting job: Dry run for RepoLiveSharpUpdateFailsWithMatBlazor.Client
server: 1.6.7.0
Hosting environment: Production
nuget: 1.6.36
Content root path: C:\Users\spoil\.nuget\packages\livesharp\1.6.36\build\Workspace
Now listening on: http://127.0.0.1:56428
Application started. Press Ctrl+C to shut down.
17:30:08.106: Ended job: Dry run for RepoLiveSharpUpdateFailsWithMatBlazor.Client (4526)
17:32:01.414: Starting job: Handling Razor update: Pages\Index.razor
17:32:01.606: Updating obj\Debug\net5.0\Razor\Pages\Index.razor.g.cs
17:32:01.708: Ended job: Handling Razor update: Pages\Index.razor (290)
17:32:01.725: Received C# update
...

Microsoft.JSInterop.WebAssembly error

...
Application started. Press Ctrl+C to shut down.
17:30:08.106: Ended job: Dry run for RepoLiveSharpUpdateFailsWithMatBlazor.Client (4526)
17:32:01.414: Starting job: Handling Razor update: Pages\Index.razor
17:32:01.606: Updating obj\Debug\net5.0\Razor\Pages\Index.razor.g.cs
17:32:01.708: Ended job: Handling Razor update: Pages\Index.razor (290)
17:32:01.725: Received C# update
17:32:02.294: warning: ReflectionTypeLoadException Microsoft.JSInterop.WebAssembly, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60: Unable to load one or more of the requested types.
Generic method or method in generic class is internal call, PInvoke, or is defined in a COM Import class.
Could not load type 'WebAssembly.JSInterop.JSCallInfo' from assembly 'Microsoft.JSInterop.WebAssembly, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' because it contains an object field at offset 4 that is incorrectly aligned or overlapped by a non-object field.
17:32:02.333: Received update for field Index.<Test>k__BackingField
17:32:02.335: Received update for field Index+<>c.<>9__13_0
17:32:02.337: Received update for field Index+<>c.<>9__13_1
17:32:02.339: Received update for field Index+<OnInitializedAsync>d__13.<>1__state
17:32:02.341: Received update for field Index+<OnInitializedAsync>d__13.<>t__builder
17:32:02.342: Received update for field Index+<OnInitializedAsync>d__13.<>4__this
17:32:02.343: Received update for field Index+<OnInitializedAsync>d__13.<assemblies>5__1
17:32:02.344: Received update for field Index+<OnInitializedAsync>d__13.<assemblyInfos>5__2
17:32:02.346: Received update for method RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.get_Test
17:32:02.347: Received update for method RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.set_Test
17:32:02.348: Received update for method RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index.OnInitializedAsync
17:32:02.349: Received update for method RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<OnInitializedAsync>b__13_0
17:32:02.350: Received update for method RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<>c.<OnInitializedAsync>b__13_1
17:32:02.350: Received update for method RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<OnInitializedAsync>d__13..ctor
17:32:02.351: Received update for method RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<OnInitializedAsync>d__13.MoveNext
17:32:02.351: Received update for method RepoLiveSharpUpdateFailsWithMatBlazor.Client.Pages.Index+<OnInitializedAsync>d__13.SetStateMachine
17:32:02.351: Received update for property Index.Test
vertonghenb commented 3 years ago

Same with adding a parameter and starting to use it in another component.

  1. Create a new component
  2. Use it in another component
  3. Add a parameter in the child component (created in step 1.)
  4. Use the parameter in the parent component.
[Parameter] public string Name {get;set;}
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Object of type 'Append.Blazor.Components.Component1' does not have a property matching the name 'Middlename'.

Afterwards the livesharp crashes:

System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it.
 ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at LiveSharp.Dashboard.WorkspaceInitializer.CheckForNuGetUpdates()
dpozimski commented 3 years ago

have the same issue too, livesharp works on C# classes (wasm), however when I switch to razor files and my file contains @click=(args => SomeAction()) hot reload stops work

warappa commented 3 years ago

@dpozimski It looks like this issue i had lately: https://github.com/OYIon/LiveSharp/issues/117

Solution: Update to version 2.0.13 (only available in Gitter chat https://gitter.im/LiveSharp/lobby). Don't forget to update the server tool also - 2.0.6 I think.