visual-studiotemplatesf#

F#/VS2022 - Can I make the default module name in new .fs files include the namespace?


In F# in Visual Studio 2022, when I Add (Above/Below) -> New Item -> Source File and give it a name (e.g. "FileName"), it is created with this default text:

module FileName

I would like it to default to text that contains the namespace, e.g.:

module ProjectName.FileName

What is the easiest way to accomplish this?


Solution

  • I didn't find a setting, but you can create an item template for this (link).

    I created a template file containing:

    module $rootnamespace$.$safeitemname$

    When adding an item, it shows up like this: enter image description here