Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.VisualStudio/18.vNext.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Code-fixes for FS3888 (compiler-semantic attribute on the `.fs` but not the `.fsi`): copy the attribute into the `.fsi`, or remove it from the `.fs`. ([Issue #19560](https://github.com/dotnet/fsharp/issues/19560), [PR #19880](https://github.com/dotnet/fsharp/pull/19880))
* Expand `<inheritdoc/>` in IDE tooltips, completion, and signature help, inheriting XML documentation from base classes, interfaces, overridden members, and constructors. ([Issue #19175](https://github.com/dotnet/fsharp/issues/19175), [PR #19188](https://github.com/dotnet/fsharp/pull/19188))
* Code snippets for F#: **Insert Snippet** (Ctrl+K,Ctrl+X), **Surround With** (Ctrl+K,Ctrl+S), Tab expansion of a snippet shortcut, and 40 built-in snippets listed under **Tools ▸ Code Snippets Manager**. `ctor` and `equals` fill in the enclosing type name, and `match` generates the cases of the union or enum it is given. ([Issue #1498](https://github.com/dotnet/fsharp/issues/1498), [PR #20521](https://github.com/dotnet/fsharp/pull/20521))

### Fixed

Expand Down
19 changes: 19 additions & 0 deletions vsintegration/Vsix/RegisterFsharpPackage.pkgdef
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@
"RequestStockColors"=dword:00000001
@="{35a5e6b8-4012-41fc-a652-2cdc56d74e9f}"

; Code snippets. The default value is the GUID FSharpSnippetExpansionClient passes to
; InvokeInsertionUI and GetExpansionByShortcut, "LangStringID" has to match every snippet's
; <Code Language="...">, and "DisplayName" resolves against the package named below.
; Only 1033 ships, so the paths name it outright: registering both %LCID% and a literal 1033
; would enumerate every snippet twice on an English VS.
[$RootKey$\Languages\CodeExpansions\FSharp]
@="{bc6dd5a5-d4d6-4dab-a00d-a51242dbaf1b}"
"Package"="{871d2a70-12a2-4e42-9440-425dd92a4116}"
"DisplayName"="#100"
"LangStringID"="FSharp"
"IndexPath"="$PackageFolder$\Snippets\1033\SnippetsIndex.xml"
"ShowRoots"=dword:00000000

[$RootKey$\Languages\CodeExpansions\FSharp\Paths]
"Visual F#"="$PackageFolder$\Snippets\1033\FSharp\;%MyDocs%\Code Snippets\Visual F#\My Code Snippets\"

[$RootKey$\Languages\CodeExpansions\FSharp\ForceCreateDirs]
"Visual F#"="%MyDocs%\Code Snippets\Visual F#\My Code Snippets\"

[$RootKey$\FontAndColors\FSharpInteractive]
"Category"="{00CCEE86-3140-4E06-A65A-A92665A40D6F}"
"Package"="{F5E7E71D-1401-11D1-883B-0000F87579D2}"
Expand Down
14 changes: 14 additions & 0 deletions vsintegration/Vsix/VisualFSharpFull/VisualFSharp.Core.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
<Link>License.txt</Link>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>

<!-- The code snippet catalog, laid out as RegisterFsharpPackage.pkgdef's CodeExpansions paths
expect to find it under $PackageFolder$. -->
<Content Include="$(MSBuildThisFileDirectory)snippets\1033\SnippetsIndex.xml">
<VSIXSubPath>Snippets\1033</VSIXSubPath>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>

<!-- The directory is `FSharp`, not `Visual F#`, because a '#' in a VSIX part URI reads as a URI
fragment and the packaging step refuses it. SnippetsIndex.xml supplies the display name. -->
<Content Include="$(MSBuildThisFileDirectory)snippets\1033\FSharp\*.snippet">
<VSIXSubPath>Snippets\1033\FSharp</VSIXSubPath>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>abstract</Title>
<Shortcut>abstract</Shortcut>
<Description>Code snippet for an abstract member</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Member name</ToolTip>
<Default>Member</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Parameter type</ToolTip>
<Default>int</Default>
</Literal>
<Literal>
<ID>returnType</ID>
<ToolTip>Return type</ToolTip>
<Default>unit</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[abstract member $name$: $type$ -> $returnType$
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>async</Title>
<Shortcut>async</Shortcut>
<Description>Code snippet for an async expression</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="FSharp"><![CDATA[async {
$selected$$end$
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>attribute</Title>
<Shortcut>attribute</Shortcut>
<Description>Code snippet for a custom attribute</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Attribute name, without the Attribute suffix</ToolTip>
<Default>My</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[type $name$Attribute() =
inherit System.Attribute()
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>class</Title>
<Shortcut>class</Shortcut>
<Description>Code snippet for a class type</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Class name</ToolTip>
<Default>MyClass</Default>
</Literal>
<Literal>
<ID>member</ID>
<ToolTip>Member name</ToolTip>
<Default>Method</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[type $name$() =
member _.$member$() = $end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>ctor</Title>
<Shortcut>ctor</Shortcut>
<Description>Code snippet for an additional constructor</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>arguments</ID>
<ToolTip>Constructor arguments</ToolTip>
<Default>arg: int</Default>
</Literal>
<Literal Editable="false">
<ID>classname</ID>
<ToolTip>Class name</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
<Literal>
<ID>values</ID>
<ToolTip>Arguments passed to the primary constructor</ToolTip>
<Default>arg</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[new($arguments$) = $classname$($values$)
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>dispose</Title>
<Shortcut>dispose</Shortcut>
<Description>Code snippet for an IDisposable implementation</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Code Language="FSharp"><![CDATA[interface System.IDisposable with
member this.Dispose() =
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>du</Title>
<Shortcut>du</Shortcut>
<Description>Code snippet for a discriminated union type</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Union name</ToolTip>
<Default>MyUnion</Default>
</Literal>
<Literal>
<ID>case1</ID>
<ToolTip>First case</ToolTip>
<Default>Case1</Default>
</Literal>
<Literal>
<ID>case2</ID>
<ToolTip>Second case</ToolTip>
<Default>Case2</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Field type of the second case</ToolTip>
<Default>int</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[type $name$ =
| $case1$
| $case2$ of $type$
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>enum</Title>
<Shortcut>enum</Shortcut>
<Description>Code snippet for an enum type</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Enum name</ToolTip>
<Default>MyEnum</Default>
</Literal>
<Literal>
<ID>case</ID>
<ToolTip>First value</ToolTip>
<Default>Value</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[type $name$ =
| $case$ = 0
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>equals</Title>
<Shortcut>equals</Shortcut>
<Description>Code snippet for Equals and GetHashCode overrides</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="false">
<ID>classname</ID>
<ToolTip>Class name</ToolTip>
<Function>ClassName()</Function>
<Default>ClassNamePlaceholder</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[override this.Equals(other) =
match other with
| :? $classname$ as other -> $end$
| _ -> false

override this.GetHashCode() = 0]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>exn</Title>
<Shortcut>exn</Shortcut>
<Description>Code snippet for an exception declaration</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>name</ID>
<ToolTip>Exception name</ToolTip>
<Default>MyException</Default>
</Literal>
<Literal>
<ID>type</ID>
<ToolTip>Carried data</ToolTip>
<Default>string</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[exception $name$ of $type$
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>ext</Title>
<Shortcut>ext</Shortcut>
<Description>Code snippet for a type extension</Description>
<Author>Microsoft Corporation</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>type</ID>
<ToolTip>Type to extend</ToolTip>
<Default>System.String</Default>
</Literal>
<Literal>
<ID>member</ID>
<ToolTip>Member name</ToolTip>
<Default>Member</Default>
</Literal>
</Declarations>
<Code Language="FSharp"><![CDATA[type $type$ with
member this.$member$() =
$end$]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Loading
Loading