KreativJos / csharpextensions

C# Extensions for Visual Studio Code
MIT License
74 stars 34 forks source link

Cannot read properties of undefined (reading 'properties') #102

Closed Alluseri closed 2 years ago

Alluseri commented 2 years ago

Describe the bug Running the "csharpextensions.ctorFromProperties" command yields the error "Cannot read properties of undefined (reading 'properties')". See the subject source code in screenshots.

Context

Expected behavior A constructor would be generated for my class properties.

Screenshots

KreativJos commented 2 years ago

There are no properties in the class you created, which is why the command is not shown. Those items are public fields (which is a bad practice). You could use the 'Generate constructor' function from omnisharp, which works by selecting all text with fields / properties and then generates a constructor with those fields / properties.