Steps to Reproduce:
public class Foo
{
public Foo(string bar)
{
Bar = bar;
}
}
Expected Behavior:
Provide an option to generate a getter-only auto property. Preferably as the first option.
Actual Behavior:
Options to generate:

Raised by request in #17621
Also it would be nice to put "generate" code actions into separate sub menus for fields and properties.
Also it would be nice to put "generate" code actions into separate sub menus for fields and properties.
Generate code actions will be placed into separate sub menus if we have too many items to show. They actually are generated as sub-items by the fixer. we just actually elevate the nested items to tp-level items if there are not that many items to show.
@DustinCampbell @Pilchie . I'm leaning toward always generating an auto-prop if you're in the constructor. Do you have any issue with the default just becoming that? I think i'd prefer that over having "generate property" and "generate auto-property" in the same list.
What do you think?
My ideal would be that generate always generates an autoproperty (if on a langver high enough to support it), and that we offer a refactoring on auto-properties to convert to a full property and introduce a backing field.
Perhaps worth a code style option?
I think it's reasonable to lean towards immutability by default and make it easy to switch to mutable fields/properties if needed :+1:
@CyrusNajmabadi @Pilchie I don't think this issue is about generating autoproperty, that is already the case as shown in the screenshot (and the one I suggested code style option for). I think this issue is about missing the property equivalent of "read-only field".
This has been fixed, and is now the default:

Thanks, @CyrusNajmabadi! :heart:
Most helpful comment
My ideal would be that generate always generates an autoproperty (if on a langver high enough to support it), and that we offer a refactoring on auto-properties to convert to a full property and introduce a backing field.