-
How can the source code generator generate code immediately when inputting instead of waiting until compilation? The following code has two opportunities to generate code. public struct PacketTest
{
public Fixed10<>... //case 1: I need generate Fixed10<T>'s code when after input "Fixed10<> "
public Fixed10<PData> Field1; //case 2: I need generate Fixed10<T>'s code when after input "public Fixed10<PData> Field1; "
}
public struct PData{
public byte Seq;
public int Len;
public byte Flags;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think this is not possible, because Roslyn source generators are by definition executed during normal compilation, not by some separate tool or the IDE. |
Beta Was this translation helpful? Give feedback.
-
i have soloved, |
Beta Was this translation helpful? Give feedback.
i have soloved,
I have solved the problem. In fact, the source code generator + VS can detect code changes in near real-time. The reason why it does not work is simply because you need to compile the source code generator and then restart VS. Then wait for the project to be completely loaded, and then Switch to the corresponding code page, and then the debugger [Debugger.Launch();] will take effect.