From 0035861ed5d8b5bb8d22d6532d72ed4c4f3f72f5 Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Fri, 24 Dec 2021 13:26:52 -0800 Subject: [PATCH 1/2] System.AttributeTargets F# snippets --- .../VS_Snippets_CLR/AttrTargs/FS/attrtargs.fs | 54 +++++++++++++++++++ .../VS_Snippets_CLR/AttrTargs/FS/fs.fsproj | 9 ++++ 2 files changed, 63 insertions(+) create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/attrtargs.fs create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/fs.fsproj diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/attrtargs.fs b/samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/attrtargs.fs new file mode 100644 index 00000000000..bc6b96b1494 --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/attrtargs.fs @@ -0,0 +1,54 @@ +// +open System + +// This attribute is only valid on a class. +[] +type ClassTargetAttribute() = + inherit Attribute() + +// This attribute is only valid on a method. +[] +type MethodTargetAttribute() = + inherit Attribute() + +// This attribute is only valid on a constructor. +[] +type ConstructorTargetAttribute() = + inherit Attribute() + +// This attribute is only valid on a field. +[] +type FieldTargetAttribute() = + inherit Attribute() + +// This attribute is valid on a class or a method. +[] +type ClassMethodTargetAttribute() = + inherit Attribute() + +// This attribute is valid on a generic type parameter. +[] +type GenericParameterTargetAttribute() = + inherit Attribute() + +// This attribute is valid on any target. +[] +type AllTargetsAttribute() = + inherit Attribute() + +[] +[] +[] +type TestClassAttribute [] [] () = + [] + [] + let myInt = 0 + + [] + [] + [] + member _.Method1() = () + + member _.GenericMethod<[] 'T>(x: 'T) = () + +// \ No newline at end of file diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/fs.fsproj new file mode 100644 index 00000000000..56d76066c6d --- /dev/null +++ b/samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/fs.fsproj @@ -0,0 +1,9 @@ + + + Exe + net6.0 + + + + + \ No newline at end of file From 57ec1347246f0edba2d75099260f89730a900582 Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Fri, 24 Dec 2021 14:41:39 -0800 Subject: [PATCH 2/2] Update AttributeTargets.xml --- xml/System/AttributeTargets.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/xml/System/AttributeTargets.xml b/xml/System/AttributeTargets.xml index f559fc41bca..7559453cafb 100644 --- a/xml/System/AttributeTargets.xml +++ b/xml/System/AttributeTargets.xml @@ -72,6 +72,7 @@ :::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/AttrTargs/CPP/attrtargs.cpp" id="Snippet1"::: :::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/AttrTargs/CS/attrtargs.cs" id="Snippet1"::: + :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/attrtargs.fs" id="Snippet1"::: :::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/AttrTargs/VB/AttrTargs.vb" id="Snippet1"::: ]]>