OYIon / LiveSharp

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

Wrong result on modified class property getter #115

Closed Jonas-Degn closed 3 years ago

Jonas-Degn commented 3 years ago

C#, .NET 5.0, Blazor Server, running more or less a standard blazor template in server mode, not WASM.

ServerVersion 1.7.2.0 Nuget 1.6.52

I have a very simple class like this:

    public class WeatherForecast
    {
        public DateTime Date { get; set; }
        public int TemperatureC { get; set; }
        public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
        public string Summary { get; set; }
    }

Then I change TemperatureF to 320 + (int)(TemperatureC / 0.5556); expecting new logic to run for that getter method. I have also tried manually defining it as a getter with the oldschool { get { return 320 + (int)(TemperatureC / 0.5556); } }, same issue.

Livesharp server log goes:

16:23:52.625: Ended job: Dry run for Frontend (1470)
16:24:10.784: Starting job: Handling C# update: Data\WeatherForecast.cs
16:24:10.839: Updating Data\WeatherForecast.cs
16:24:10.869: Ended job: Handling C# update: Data\WeatherForecast.cs (84)
16:24:10.873: Received C# update
16:24:10.880: Received update for method Data.WeatherForecast.get_TemperatureF
16:24:10.902: warning: No components found to update Data.WeatherForecast

I refresh the browser page and result goes from 32+calculation to 320 for all TemperatureF, which indicates that the entire +calculation somehow disappeared in the hot-reload. Doing a manual stop, compile, start, fixes the issue, but kinda not the point of using LiveSharp.

I asked about it on Discord, you called it a bug and asked me to create an issue on it, here it is :)

ionoy commented 3 years ago

(Sorry about the board, it was indeed my private project and I didn't expect the automatic comment here)

Anyway, I tried following your steps with the default Blazor application and I get the correct calculation after switching between the pages. I'm not sure if missing something here.