I wrote the same code using Visual Studio 2022, copied it from the object inspector, then pasted it into Visual Studio Code.