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

C# hot reload - no code changes were found #1450

Open
davidortinau opened this issue Sep 9, 2024 · 8 comments
Open

C# hot reload - no code changes were found #1450

davidortinau opened this issue Sep 9, 2024 · 8 comments
Labels
area-hotreload Issues with Hot Reload experiences bug Something isn't working

Comments

@davidortinau
Copy link
Member

Type: Bug

In this version I'm unable to C# hot reload. I've cleared my bin/obj folders. All I get in the output is messages like this. I'm using .NET 9 Preview 7 and targeting net9.0-maccatalyst and net9.0-ios.

2024-09-08 21:33:51.865 [info] 💡 Possible changes were found.
2024-09-08 21:33:58.458 [info] No code changes were found.
2024-09-08 21:34:03.646 [info] No code changes were found.
2024-09-08 21:50:37.817 [info] 💡 Possible changes were found.
2024-09-08 22:01:54.861 [info] 💡 Possible changes were found.
2024-09-08 22:02:02.824 [info] No code changes were found.

Extension version: 1.11.4
VS Code version: Code - Insiders 1.93.0-insider (4849ca9bdf9666755eb463db297b69e5385090e3, 2024-09-04T13:13:15.344Z)
OS version: Darwin arm64 23.6.0
Modes:

System Info
Item Value
CPUs Apple M1 Pro (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 3, 4, 4
Memory (System) 16.00GB (0.06GB free)
Process Argv --crash-reporter-id fc80353a-ef2a-479f-83ff-be5b061d3542
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vsc_aacf:30263846
vscod805:30301674
vsaa593:30376534
py29gd2263:31024238
c4g48928:30535728
962ge761:30841072
pythongtdpath:30726887
welcomedialog:30812478
pythonnoceb:30776497
asynctok:30898717
dsvsc014:30777825
dsvsc015:30821418
pythonmypyd1:30859725
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30870582
dsvsc016:30879898
dsvsc017:30880771
dsvsc018:30880772
cppperfnew:30980852
pythonait:30973460
9c06g630:31013171
a69g1124:31018687
dvdeprecation:31040973
dwnewjupytercf:31046870
nb_pkg_only:31057982
nativerepl1:31104042
refactort:31084545
pythonrstrctxt:31093868
flighttreat:31119334
wkspc-onlycs-t:31132770
nativeloc1:31118317
wkspc-ranged-t:31125599
cf971741:31111988
jh802675:31132134
e80f6927:31120813
ei213698:31121563

@BretJohnson
Copy link
Member

BretJohnson commented Sep 9, 2024

@davidortinau - Can you set the environment variable below to enable more logs for C# Hot Reload, then attach them.
In the past that's been the next step for "no code changes are found" when there are code changes troubleshooting. Thanks.

Also, can you note the versions of the C#, C# DevKit, and MAUI extensions you are using. They are internal versions, what's about to be published to prerelease tomorrow, right?

  1. Run the following commands from Developer Command Prompt for Visual Studio:
**********************************************************************
** Visual Studio 2022 Developer Command Prompt
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
 
C:\Program Files\Microsoft Visual Studio\2022\Preview> set Microsoft_CodeAnalysis_EditAndContinue_LogDir=%temp%\HotReloadLog
C:\Program Files\Microsoft Visual Studio\2022\Preview> devenv  [or launch vscode or dotnet watch]

then you apply C# hot reload, the change applied will be output at %temp%\HotReloadLog

@davidortinau
Copy link
Member Author

@BretJohnson correct, I'm on pre-release of everything here.

MAUI v1.3.29
DevKit v1.11.4
C# v2.46.32

@phil-allen-msft phil-allen-msft added the area-hotreload Issues with Hot Reload experiences label Sep 11, 2024
@webreidi webreidi added the bug Something isn't working label Sep 11, 2024
@lucasmsoares96
Copy link

Any progress on this?

@BretJohnson
Copy link
Member

Any progress on this?

@lucasmsoares96 - Assuming you see this issue, would you mind following the steps here, attaching the logs: #1450 (comment). Thanks much.

@lucasmsoares96
Copy link

The problem is intermittent and occurs in different contexts.

Versions:

Extensions:

  • C#: v2.52.24 (pre-release)
  • C# Dev Kit v1.12.16 (pre-release)
  • (I'm not using MAUI)

Binaries

  • dotnet 8.0.403

Log files

Analysis.log

Capabilities required by '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs': Baseline, AddInstanceFieldToExistingType
Capabilities required by '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs': Baseline, AddInstanceFieldToExistingType
Capabilities required by '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs': Baseline, AddInstanceFieldToExistingType
Document unchanged: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/Chatbot.cs'
Capabilities required by '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs': Baseline, AddInstanceFieldToExistingType
Capabilities required by '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs': Baseline, AddInstanceFieldToExistingType

Trace.log

Debugging session started: #1
Session #1 started.
Edit session restarted (break state: null)
EmitSolutionUpdate 1.1: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Solution update 1.1 status: None
EmitSolutionUpdate 1.2: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Document changed, added, or deleted: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': ValidChanges
Emitting update of 'csharp-semantic-kernel' /Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj
Solution update 1.2 status: Ready
Module update: capabilities=[Baseline,AddInstanceFieldToExistingType], types=[02000005,0200000C,0200000D], methods=[0600000D,06000030]
Edit session restarted (break state: False)
EmitSolutionUpdate 1.3: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Solution update 1.3 status: None
EmitSolutionUpdate 1.4: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Solution update 1.4 status: None
EmitSolutionUpdate 1.5: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Document changed, added, or deleted: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': ValidChanges
Emitting update of 'csharp-semantic-kernel' /Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj
Solution update 1.5 status: Ready
Module update: capabilities=[Baseline,AddInstanceFieldToExistingType], types=[02000005,0200000C,0200000D], methods=[0600000D,06000030]
Edit session restarted (break state: False)
EmitSolutionUpdate 1.6: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Document changed, added, or deleted: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': ValidChanges
Emitting update of 'csharp-semantic-kernel' /Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj
Solution update 1.6 status: Ready
Module update: capabilities=[Baseline,AddInstanceFieldToExistingType], types=[02000005,0200000C,0200000D], methods=[0600000D,06000030]
Edit session restarted (break state: False)
EmitSolutionUpdate 1.7: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Solution update 1.7 status: None
EmitSolutionUpdate 1.8: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 2 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Document changed, added, or deleted: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': ValidChanges
Emitting update of 'csharp-semantic-kernel' /Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj
Solution update 1.8 status: Ready
Module update: capabilities=[Baseline,AddInstanceFieldToExistingType], types=[02000005,0200000C,0200000D], methods=[0600000D,06000030]
Edit session restarted (break state: False)
EmitSolutionUpdate 1.9: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Document changed, added, or deleted: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': ValidChanges
Emitting update of 'csharp-semantic-kernel' /Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj
Solution update 1.9 status: Ready
Module update: capabilities=[Baseline,AddInstanceFieldToExistingType], types=[02000005,0200000C,0200000D], methods=[0600000D,06000030]
Edit session restarted (break state: False)
EmitSolutionUpdate 1.10: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Checksum differs for source file '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/LightsPlugin.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': NoChanges
Solution update 1.10 status: None
EmitSolutionUpdate 1.11: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Checksum differs for source file '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/LightsPlugin.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': NoChanges
Solution update 1.11 status: None
EmitSolutionUpdate 1.12: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Checksum differs for source file '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/LightsPlugin.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': NoChanges
Solution update 1.12 status: None
EmitSolutionUpdate 1.13: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Solution update 1.13 status: None
EmitSolutionUpdate 1.14: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Solution update 1.14 status: None

Did I forget something?

@BretJohnson
Copy link
Member

BretJohnson commented Oct 17, 2024

@lucasmsoares96 Thanks. What is the .cs source file that should have had changes reported here, in the logs above?
Also, can you describe, in general terms, what the code change was when this happened. Was it say adding a method, changing code in an existing method, changing a method signature, something else, etc.? Thanks again for info.

@lucasmsoares96
Copy link

In the logs above, changes were made to 2 files: WebApp.cs and LightsPlugin.cs. In WebApp.cs, the returns were commented and uncommented (which worked fine), and in LightsPlugin.cs, the ChangeStateAsync method was added and removed (which did not work).

WebApp.cs

class WebApp
{
  static void Main(string[] args)
  {
    var builder = WebApplication.CreateBuilder(args);
    var app = builder.Build();
    var chatbot = new Chatbot();

    app.MapPost("/ChatMessages", async (ChatMessages person) =>
    {
      Console.WriteLine(person);
      var result = await chatbot.StartAsync(person.Text);
      return Results.Ok("empty return");   // comment this
      // return Results.Ok(result.Content); // uncomment this
    });
    app.Run();
  }
  record ChatMessages(string User, string Text);
}

LightsPlugin.cs

using System.ComponentModel;
using System.Text.Json.Serialization;
using Microsoft.SemanticKernel;

public class LightsPlugin
{
  private readonly List<LightModel> lights = new()
   {
      new LightModel { Id = 1, Name = "Table Lamp", IsOn = false },
      new LightModel { Id = 2, Name = "Porch light", IsOn = false },
      new LightModel { Id = 3, Name = "Chandelier", IsOn = true }
   };

  [KernelFunction("get_lights")]
  [Description("Gets a list of lights and their current state")]
  [return: Description("An array of lights")]
  public async Task<List<LightModel>> GetLightsAsync()
  {
    return lights;
  }

  [KernelFunction("change_state")]
  [Description("Changes the state of the light")]
  [return: Description("The updated state of the light; will return null if the light does not exist")]
  public async Task<LightModel?> ChangeStateAsync(int id, bool isOn)
  {
    var light = lights.FirstOrDefault(light => light.Id == id);

    if (light == null)
    {
      return null;
    }

    light.IsOn = isOn;

    return light;
  }
}

public class LightModel
{
  [JsonPropertyName("id")]
  public int Id { get; set; }

  [JsonPropertyName("name")]
  public string Name { get; set; }

  [JsonPropertyName("is_on")]
  public bool? IsOn { get; set; }
}

When I finished restarting the debug, experiment 1 (commenting and uncommenting the returns line in file 1) stopped working.

Logs

Trace.log

Debugging session started: #2
Session #2 started.
Edit session restarted (break state: null)
EmitSolutionUpdate 2.1: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Checksum differs for source file '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': NoChanges
Solution update 2.1 status: None
EmitSolutionUpdate 2.2: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Solution update 2.2 status: None
EmitSolutionUpdate 2.3: '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.sln'
Found 1 potentially changed document(s) in project csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj'
Checksum differs for source file '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/src/WebApp.cs'
Project summary for csharp-semantic-kernel '/Users/lucas/Desktop/Bytewer/Viveza/Csharp/csharp-semantic-kernel.csproj': NoChanges
Solution update 2.3 status: None

@lucasmsoares96
Copy link

One more thing: the hot reload button is also not working.

Image

uname -a
Darwin Lucass-MacBook-Pro.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:30 PDT 2024; root:xnu-11215.1.12~1/RELEASE_X86_64 x86_64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-hotreload Issues with Hot Reload experiences bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants