From 7a2b45531647e78b8d3548379e71502e19efadf2 Mon Sep 17 00:00:00 2001
From: albert-du <52804499+albert-du@users.noreply.github.com>
Date: Thu, 23 Dec 2021 21:21:25 -0800
Subject: [PATCH 1/3] System.Attribute F# snippets
---
.../AnimalAttributes/FS/customattribute.fs | 41 +++++++
.../AnimalAttributes/FS/fs.fsproj | 9 ++
.../GetCustomAttributes/FS/ca1.fs | 35 ++++++
.../GetCustomAttributes/FS/ca2.fs | 36 ++++++
.../GetCustomAttributes/FS/ca4.fs | 69 ++++++++++++
.../GetCustomAttributes/FS/ca5.fs | 42 +++++++
.../GetCustomAttributes/FS/fs.fsproj | 12 ++
.../VS_Snippets_CLR/GetHashCode/FS/fs.fsproj | 9 ++
.../GetHashCode/FS/hashcode.fs | 71 ++++++++++++
.../IsDefaultAttribute/FS/defattr.fs | 46 ++++++++
.../IsDefaultAttribute/FS/fs.fsproj | 9 ++
.../IsDefined/FS/IsDef1FS.fsproj | 12 ++
.../VS_Snippets_CLR/IsDefined/FS/id1.fs | 47 ++++++++
.../VS_Snippets_CLR/IsDefined/FS/id2.fs | 40 +++++++
.../VS_Snippets_CLR/IsDefined/FS/id4.fs | 38 +++++++
.../VS_Snippets_CLR/IsDefined/FS/id5.fs | 31 +++++
.../fsharp/VS_Snippets_CLR/Match/FS/fs.fsproj | 9 ++
.../fsharp/VS_Snippets_CLR/Match/FS/match.fs | 88 +++++++++++++++
.../system.Attribute.Equals/FS/equals.fs | 105 +++++++++++++++++
.../system.Attribute.Equals/FS/fs.fsproj | 9 ++
.../FS/fs.fsproj | 10 ++
.../FS/getcustattrparam.fs | 80 +++++++++++++
.../FS/getcustattrprminh.fs | 106 ++++++++++++++++++
.../system.Attribute.TypeId/FS/fs.fsproj | 9 ++
.../system.Attribute.TypeId/FS/typeid.fs | 95 ++++++++++++++++
xml/System/Attribute.xml | 39 +++++++
26 files changed, 1097 insertions(+)
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/fs.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/fs.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/fs.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/hashcode.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/defattr.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/fs.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/IsDef1FS.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id5.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/fs.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/match.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/equals.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/fs.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/fs.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrparam.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrprminh.fs
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/fs.fsproj
create mode 100644 samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/typeid.fs
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs b/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs
new file mode 100644
index 00000000000..f7cc1f7b6f7
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs
@@ -0,0 +1,41 @@
+//
+open System
+
+// An enumeration of animals. Start at 1 (0 = uninitialized).
+type Animal =
+ | Dog = 1
+ | Cat = 2
+ | Bird = 3
+
+// A custom attribute to allow a target to have a pet.
+type AnimalTypeAttribute(pet) =
+ inherit Attribute()
+ member val Pet = pet with get, set
+
+// A test class where each method has its own pet.
+type AnimalTypeTestClass() =
+ []
+ member _.DogMethod() = ()
+
+ []
+ member _.CatMethod() = ()
+
+ []
+ member _.BirdMethod() = ()
+
+let testClass = AnimalTypeTestClass()
+let type' = testClass.GetType()
+// Iterate through all the methods of the class.
+for mInfo in type'.GetMethods() do
+ // Iterate through all the Attributes for each method.
+ for attr in Attribute.GetCustomAttributes mInfo do
+ // Check for the AnimalType attribute.
+ if attr.GetType() = typeof then
+ printfn $"Method {mInfo.Name} has a pet {(attr :?> AnimalTypeAttribute).Pet} attribute."
+
+// Output:
+// Method DogMethod has a pet Dog attribute.
+// Method CatMethod has a pet Cat attribute.
+// Method BirdMethod has a pet Bird attribute.
+
+//
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/fs.fsproj
new file mode 100644
index 00000000000..14f581f9a75
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/fs.fsproj
@@ -0,0 +1,9 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs
new file mode 100644
index 00000000000..933a65de21c
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs
@@ -0,0 +1,35 @@
+module ca1
+
+//
+open System
+open System.Reflection
+
+[]
+[]
+[]
+do ()
+
+type Example = class end
+
+// Get the Assembly object to access its metadata.
+let assembly = typeof.Assembly
+
+// Iterate through the attributes for the assembly.
+for attr in Attribute.GetCustomAttributes assembly do
+ match attr with
+ // Check for the AssemblyTitle attribute.
+ | :? AssemblyTitleAttribute as attr ->
+ printfn $"Assembly title is \"{attr.Title}\"."
+ // Check for the AssemblyDescription attribute.
+ | :? AssemblyDescriptionAttribute as attr ->
+ printfn $"Assembly description is \"{attr.Description}\"."
+ // Check for the AssemblyCompany attribute.
+ | :? AssemblyCompanyAttribute as attr ->
+ printfn $"Assembly company is {attr.Company}."
+ | _ -> ()
+
+// The example displays the following output:
+// Assembly title is "CustAttrs1CS".
+// Assembly description is "GetCustomAttributes() Demo".
+// Assembly company is Microsoft.
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs
new file mode 100644
index 00000000000..ec32d976c1f
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs
@@ -0,0 +1,36 @@
+module ca2
+
+//
+open System
+open System.ComponentModel
+
+// Assign some attributes to the module.
+[<``module``: Description "A sample description">]
+
+// Set the module's CLSCompliant attribute to false
+// The CLSCompliant attribute is applicable for /target:module.
+[<``module``: CLSCompliant false>]
+do ()
+
+type DemoClass = class end
+
+// Get the Module type to access its metadata.
+let module' = typeof.Module
+
+// Iterate through all the attributes for the module.
+for attr in Attribute.GetCustomAttributes module' do
+ match attr with
+ // Check for the Description attribute.
+ | :? DescriptionAttribute as attr ->
+ printfn $"Module {module'.Name} has the description \"{attr.Description}\"."
+
+ // Check for the CLSCompliant attribute.
+ | :? CLSCompliantAttribute as attr ->
+ printfn $"""Module {module'.Name} {if attr.IsCompliant then "is" else "is not"} CLSCompliant."""
+ | _ -> ()
+
+// Output:
+// Module CustAttrs2CS.exe is not CLSCompliant.
+// Module CustAttrs2CS.exe has the description "A sample description".
+
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs
new file mode 100644
index 00000000000..a1a2fc6e66e
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs
@@ -0,0 +1,69 @@
+module ca4
+
+//
+open System
+open System.Runtime.InteropServices
+
+// Define an enumeration of Win32 unmanaged types
+type UnmanagedType =
+ | User = 0
+ | GDI = 1
+ | Kernel = 2
+ | Shell = 3
+ | Networking = 4
+ | Multimedia = 5
+
+// Define the Unmanaged attribute.
+type UnmanagedAttribute(unmanagedType) =
+ inherit Attribute()
+
+ // Define a property to get and set the UnmanagedType value.
+ member val Win32Type = unmanagedType with get, set
+
+// Create a module for an imported Win32 unmanaged function.
+module Win32 =
+ []
+ extern int MessageBox(IntPtr hWnd, String text, String caption, uint ``type``)
+
+type AClass() =
+ // Add some attributes to Win32CallMethod.
+ []
+ []
+ member _.Win32CallMethod () =
+ Win32.MessageBox(0, "This is an unmanaged call.", "Caution!", 0u)
+
+// Get the AClass type to access its metadata.
+let clsType = typeof
+// Get the type information for Win32CallMethod.
+let mInfo = clsType.GetMethod "Win32CallMethod"
+if mInfo <> null then
+ // Iterate through all the attributes of the method.
+ for attr in Attribute.GetCustomAttributes mInfo do
+ match attr with
+ // Check for the Obsolete attribute.
+ | :? ObsoleteAttribute as attr ->
+ printfn $"Method {mInfo.Name} is obsolete. The message is:"
+ printfn $" \"{attr.Message}\""
+
+ // Check for the Unmanaged attribute.
+ | :? UnmanagedAttribute as attr ->
+ printfn "This method calls unmanaged code."
+ printfn $"The Unmanaged attribute type is {attr.Win32Type}."
+ let myCls = AClass()
+ myCls.Win32CallMethod() |> ignore
+ | _ -> ()
+
+// This code example produces the following results.
+//
+// First, the compilation yields the warning, "... This method is
+// obsolete. Use managed MsgBox instead."
+// Second, execution yields a message box with a title of "Caution!"
+// and message text of "This is an unmanaged call."
+// Third, the following text is displayed in the console window:
+
+// Method Win32CallMethod is obsolete. The message is:
+// "This method is obsolete. Use managed MsgBox instead."
+// This method calls unmanaged code.
+// The Unmanaged attribute type is User.
+
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs
new file mode 100644
index 00000000000..031eeefb181
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs
@@ -0,0 +1,42 @@
+module ca5
+
+//
+open System
+open System.Reflection
+open System.ComponentModel
+
+type AClass() =
+ member _.ParamArrayAndDesc(
+ // Add ParamArray and Description attributes.
+ []
+ []
+ args: int[]) = ()
+
+// Get the Class type to access its metadata.
+let clsType = typeof
+
+// Get the type information for the method.
+let mInfo = clsType.GetMethod "ParamArrayAndDesc"
+if mInfo <> null then
+ // Get the parameter information.
+ let pInfo = mInfo.GetParameters()
+ if pInfo <> null then
+ // Iterate through all the attributes for the parameter.
+ for attr in Attribute.GetCustomAttributes pInfo[0] do
+ match attr with
+ // Check for the ParamArray attribute.
+ | :? ParamArrayAttribute ->
+ printfn $"Parameter {pInfo[0].Name} for method {mInfo.Name} has the ParamArray attribute."
+
+ // Check for the Description attribute.
+ | :? DescriptionAttribute as attr ->
+ printfn $"Parameter {pInfo[0].Name} for method {mInfo.Name} has a description attribute."
+ printfn $"The description is: \"{attr.Description}\""
+ | _ -> ()
+
+// Output:
+// Parameter args for method ParamArrayAndDesc has a description attribute.
+// The description is: "This argument is a ParamArray"
+// Parameter args for method ParamArrayAndDesc has the ParamArray attribute.
+
+//
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/fs.fsproj
new file mode 100644
index 00000000000..2bbe0330e04
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/fs.fsproj
@@ -0,0 +1,12 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/fs.fsproj
new file mode 100644
index 00000000000..230012fa32e
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/fs.fsproj
@@ -0,0 +1,9 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/hashcode.fs b/samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/hashcode.fs
new file mode 100644
index 00000000000..b1fab0c068c
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/hashcode.fs
@@ -0,0 +1,71 @@
+//
+open System
+open System.Reflection
+open System.Collections.Generic
+
+// A custom attribute to allow two authors per method.
+[]
+type AuthorsAttribute(authorName1, authorName2) =
+ inherit Attribute()
+
+ member val AuthorName1 = authorName1
+ member val AuthorName2 = authorName2
+
+ // Use the hash code of the string objects and xor them together.
+ override _.GetHashCode() =
+ authorName1.GetHashCode() ^^^ authorName2.GetHashCode()
+
+// Provide the author names for each method of the class.
+type TestClass() =
+ []
+ member _.Method1() = ()
+
+ []
+ member _.Method2() = ()
+
+ []
+ member _.Method3() = ()
+
+ []
+ member _.Method4() = ()
+
+ []
+ member _.Method5() = ()
+
+// Get the class type to access its metadata.
+let clsType = typeof
+
+// Store author information in a array of tuples.
+let authorsInfo =
+ [ // Iterate through all the methods of the class.
+ for method in clsType.GetMethods() do
+ // Get the Authors attribute for the method if it exists.
+ let authAttr =
+ Attribute.GetCustomAttribute(method, typeof) :?> AuthorsAttribute
+
+ if authAttr <> null then
+ // Add the information to the author list.
+ $"{clsType.Name}.{method.Name}", authAttr ]
+
+// Iterate through the list
+printfn "Method authors:\n"
+
+authorsInfo
+|> List.groupBy (fun (_, authors) -> authors.AuthorName1, authors.AuthorName2)
+|> List.iter (fun ((name1, name2), authors) ->
+ printfn $"{name1} and {name2}"
+ for (methodName, _) in authors do
+ printfn $" {methodName}")
+
+// The example displays the following output:
+// Method authors:
+//
+// Immanuel Kant and Lao Tzu
+// TestClass.Method1
+// TestClass.Method3
+// Jean-Paul Sartre and Friedrich Nietzsche
+// TestClass.Method2
+// TestClass.Method4
+// Immanuel Kant and Friedrich Nietzsche
+// TestClass.Method5
+//
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/defattr.fs b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/defattr.fs
new file mode 100644
index 00000000000..95946e02c64
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/defattr.fs
@@ -0,0 +1,46 @@
+//
+open System
+
+// An enumeration of animals. Start at 1 (0 = uninitialized).
+type Animal =
+ | Dog = 1
+ | Cat = 2
+ | Bird = 3
+
+// A custom attribute to allow a target to have a pet.
+type AnimalTypeAttribute(pet) =
+ inherit Attribute()
+
+ member val Pet = pet
+
+ // Override IsDefaultAttribute to return the correct response.
+ override _.IsDefaultAttribute() =
+ pet = Animal.Dog
+
+ // Provide a default constructor and make Dog the default.
+ new() = AnimalTypeAttribute Animal.Dog
+
+type TestClass() =
+ // Use the default constructor.
+ []
+ member _.Method1() = ()
+
+// Get the class type to access its metadata.
+let clsType = typeof
+
+// Get type information for the method.
+let mInfo = clsType.GetMethod "Method1"
+
+// Get the AnimalType attribute for the method.
+let atAttr =
+ Attribute.GetCustomAttribute(mInfo, typeof)
+ :?> AnimalTypeAttribute
+
+// Check to see if the default attribute is applied.
+printf $"The attribute {atAttr.Pet} for method {mInfo.Name} in class {clsType.Name} "
+printfn $"""{if atAttr.IsDefaultAttribute() then "is" else "is not"} the default for the AnimalType attribute."""
+
+// Output:
+// The attribute Dog for method Method1 in class TestClass is the default for the AnimalType attribute.
+
+//
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/fs.fsproj
new file mode 100644
index 00000000000..d016606407a
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/fs.fsproj
@@ -0,0 +1,9 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/IsDef1FS.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/IsDef1FS.fsproj
new file mode 100644
index 00000000000..b182bef989a
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/IsDef1FS.fsproj
@@ -0,0 +1,12 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs
new file mode 100644
index 00000000000..0a49cb8171d
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs
@@ -0,0 +1,47 @@
+module id1
+
+//
+open System
+open System.Reflection
+
+// Add an AssemblyDescription attribute
+[]
+do ()
+
+type DemoClass = class end
+
+// Get the class type to access its metadata.
+let clsType = typeof
+
+// Get the assembly object.
+let assembly = clsType.Assembly;
+
+// Store the assembly's name.
+let assemblyName = assembly.GetName().Name
+
+// See if the Assembly Description is defined.
+let isdef =
+ Attribute.IsDefined(assembly, typeof)
+
+if isdef then
+ // Affirm that the attribute is defined.
+ printfn $"The AssemblyDescription attribute is defined for assembly {assemblyName}."
+
+ // Get the description attribute itself.
+ let adAttr =
+ Attribute.GetCustomAttribute(assembly, typeof)
+ :?> AssemblyDescriptionAttribute
+
+ // Display the description.
+ if adAttr <> null then
+ printfn $"The description is \"{adAttr.Description}\"."
+ else
+ printfn $"The description could not be retrieved."
+else
+ printfn $"The AssemblyDescription attribute is not defined for assembly {assemblyName}."
+
+// Output:
+// The AssemblyDescription attribute is defined for assembly IsDef1FS.
+// The description is "A sample description".
+
+//
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs
new file mode 100644
index 00000000000..4d6da3fdfa5
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs
@@ -0,0 +1,40 @@
+module id2
+
+//
+open System
+open System.Diagnostics
+
+// Add the Debuggable attribute to the module.
+[<``module``: Debuggable(true, false)>]
+do ()
+
+type DemoClass = class end
+
+// Get the class type to access its metadata.
+let clsType = typeof
+
+// See if the Debuggable attribute is defined for this module.
+let isDef = Attribute.IsDefined(clsType.Module, typeof)
+
+// Display the result.
+printfn $"""The Debuggable attribute {if isDef then "is" else "is not"} defined for Module {clsType.Module.Name}."""
+
+// If the attribute is defined, display the JIT settings.
+if isDef then
+ // Retrieve the attribute itself.
+ let dbgAttr =
+ Attribute.GetCustomAttribute(clsType.Module, typeof)
+ :?> DebuggableAttribute
+
+ if dbgAttr <> null then
+ printfn $"JITTrackingEnabled is {dbgAttr.IsJITTrackingEnabled}."
+ printfn $"JITOptimizerDisabled is {dbgAttr.IsJITOptimizerDisabled}."
+ else
+ printfn "The Debuggable attribute could not be retrieved."
+
+// Output:
+// The Debuggable attribute is defined for Module IsDef2CS.exe.
+// JITTrackingEnabled is True.
+// JITOptimizerDisabled is False.
+
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs
new file mode 100644
index 00000000000..9bae992b2d2
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs
@@ -0,0 +1,38 @@
+module id4
+
+//
+open System
+
+type TestClass() =
+ // Assign the Obsolete attribute to a method.
+ []
+ member _.Method1() = ()
+ member _.Method2() = ()
+
+// Get the class type to access its metadata.
+let clsType = typeof
+
+// Get the MethodInfo object for Method1.
+let mInfo = clsType.GetMethod "Method1"
+
+// See if the Obsolete attribute is defined for this method.
+let isDef = Attribute.IsDefined(mInfo, typeof)
+
+// Display the result.
+printfn $"""The Obsolete Attribute {if isDef then "is" else "is not"} defined for {mInfo.Name} of class {clsType.Name}."""
+
+// If it's defined, display the attribute's message.
+if isDef then
+ let obsAttr =
+ Attribute.GetCustomAttribute(mInfo, typeof)
+ :?> ObsoleteAttribute
+ if obsAttr <> null then
+ printfn $"The message is: \"{obsAttr.Message}\"."
+ else
+ printfn "The message could not be retrieved."
+
+// Output:
+// The Obsolete Attribute is defined for Method1 of class TestClass.
+// The message is: "This method is obsolete. Use Method2 instead.".
+
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id5.fs b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id5.fs
new file mode 100644
index 00000000000..d2e9a21d0bb
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id5.fs
@@ -0,0 +1,31 @@
+module id5
+
+//
+open System;
+
+type TestClass() =
+ // Assign a ParamArray attribute to the parameter.
+ member _.Method1([] args: string[]) = ()
+
+// Get the class type to access its metadata.
+let clsType = typeof
+
+// Get the MethodInfo object for Method1.
+let mInfo = clsType.GetMethod "Method1"
+
+// Get the ParameterInfo array for the method parameters.
+let pInfo = mInfo.GetParameters()
+
+if pInfo <> null then
+ // See if the ParamArray attribute is defined.
+ let isDef = Attribute.IsDefined(pInfo[0], typeof)
+
+ // Display the result.
+ printfn $"""The ParamArray attribute {if isDef then "is" else "is not"} defined for parameter {pInfo[0].Name} of method {mInfo.Name}."""
+else
+ printfn $"The parameters information could not be retrieved for method {mInfo.Name}."
+
+// Output:
+// The ParamArray attribute is defined for parameter args of method Method1.
+
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/fs.fsproj
new file mode 100644
index 00000000000..207ffc7c10b
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/fs.fsproj
@@ -0,0 +1,9 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/match.fs b/samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/match.fs
new file mode 100644
index 00000000000..1ff0bce2573
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/match.fs
@@ -0,0 +1,88 @@
+open System
+
+// A custom attribute to allow multiple authors per method.
+[]
+type AuthorsAttribute([] names: string []) =
+ inherit Attribute()
+
+ member val Authors = ResizeArray names
+
+ // Determine if the object is a match to this one.
+ override this.Match(obj) =
+ match obj with
+ | :? AuthorsAttribute as authors2 ->
+ // Return true if obj and this instance are the same object reference.
+ if Object.ReferenceEquals(this, authors2) then true
+ // Return false if obj and this instance have different numbers of authors
+ elif this.Authors.Count <> authors2.Authors.Count then false
+ else
+ let authors1 = this.Authors |> set
+ let authors2 = this.Authors |> set
+ authors1 = authors2
+ | _ ->
+ // Return false if obj is null or not an AuthorsAttribute.
+ false
+
+ override this.ToString() =
+ let retval = String.Join(", ", this.Authors)
+ if retval.Trim().Length = 0 then
+ ""
+ else
+ retval
+
+// Add some authors to methods of a class.
+type TestClass() =
+ []
+ member _.Method1() = ()
+
+ []
+ member _.Method2() = ()
+
+ []
+ member _.Method3() = ()
+
+ []
+ member _.Method4() = ()
+
+// Get the type for TestClass to access its metadata.
+let clsType = typeof
+
+// Iterate through each method of the class.
+
+let mutable authors = null
+for method in clsType.GetMethods() do
+ // Check each method for the Authors attribute.
+ let authAttr =
+ Attribute.GetCustomAttribute(method, typeof)
+ :?> AuthorsAttribute
+
+ if authAttr <> null then
+ // Display the authors.
+ printfn $"{clsType.Name}.{method.Name} was authored by {authAttr}."
+
+ // Select Method1's authors as the basis for comparison.
+ if method.Name = "Method1" then
+ authors <- authAttr
+ printfn ""
+
+ else
+ // Compare first authors with the authors of this method.
+ if authors.Match authAttr then
+ printfn "TestClass.Method1 was also authored by the same team."
+
+ // Perform an equality comparison of the two attributes.
+ printfn $"""{authors} {if authors.Equals(authAttr) then "=" else "<>"} {authAttr}"""
+ printfn ""
+
+// The example displays the following output:
+// TestClass.Method1 was authored by Leo Tolstoy, John Milton.
+//
+// TestClass.Method2 was authored by Anonymous.
+// Leo Tolstoy, John Milton <> Anonymous
+//
+// TestClass.Method3 was authored by Leo Tolstoy, John Milton, Nathaniel Hawthorne.
+// Leo Tolstoy, John Milton <> Leo Tolstoy, John Milton, Nathaniel Hawthorne
+//
+// TestClass.Method4 was authored by John Milton, Leo Tolstoy.
+// TestClass.Method1 was also authored by the same team.
+// Leo Tolstoy, John Milton <> John Milton, Leo Tolstoy
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/equals.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/equals.fs
new file mode 100644
index 00000000000..cc1f4d67787
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/equals.fs
@@ -0,0 +1,105 @@
+open System
+
+// Define a custom parameter attribute that takes a single message argument.
+[]
+type ArgumentUsageAttribute(usageMsg) =
+ inherit Attribute()
+
+ // Override ToString() to append the message to what the base generates.
+ override _.ToString() =
+ $"%s{base.ToString()}: %s{usageMsg}"
+
+// Define a custom parameter attribute that generates a GUID for each instance.
+[]
+type ArgumentIDAttribute() =
+ inherit Attribute()
+
+ let instanceGUID = Guid.NewGuid()
+
+ // Override ToString() to append the GUID to what the base generates.
+ override _.ToString() =
+ $"%s{base.ToString()}: %O{instanceGUID}"
+
+type TestClass() =
+ // Assign an ArgumentID attribute to each parameter.
+ // Assign an ArgumentUsage attribute to each parameter.
+ member _.TestMethod(
+ []
+ []
+ strArray: string [],
+ []
+ []
+ []
+ strList: string []) = ()
+
+// Create Attribute objects and compare them.
+
+// Get the class type, and then get the MethodInfo object
+// for TestMethod to access its metadata.
+let clsType = typeof
+let mInfo = clsType.GetMethod "TestMethod"
+
+// There will be two elements in pInfoArray, one for each parameter.
+let pInfoArray = mInfo.GetParameters()
+if pInfoArray <> null then
+ // Create an instance of the argument usage attribute on strArray.
+ let arrayUsageAttr1 =
+ Attribute.GetCustomAttribute(pInfoArray[0], typeof)
+ :?> ArgumentUsageAttribute
+
+ // Create another instance of the argument usage attribute on strArray.
+ let arrayUsageAttr2 =
+ Attribute.GetCustomAttribute(pInfoArray[0], typeof)
+ :?> ArgumentUsageAttribute
+
+ // Create an instance of the argument usage attribute on strList.
+ let listUsageAttr =
+ Attribute.GetCustomAttribute(pInfoArray[1], typeof)
+ :?> ArgumentUsageAttribute
+
+ // Create an instance of the argument ID attribute on strArray.
+ let arrayIDAttr1 =
+ Attribute.GetCustomAttribute(pInfoArray[0], typeof)
+ :?> ArgumentIDAttribute
+
+ // Create another instance of the argument ID attribute on strArray.
+ let arrayIDAttr2 =
+ Attribute.GetCustomAttribute(pInfoArray[0], typeof)
+ :?> ArgumentIDAttribute
+
+ // Create an instance of the argument ID attribute on strList.
+ let listIDAttr =
+ Attribute.GetCustomAttribute(pInfoArray[1], typeof)
+ :?> ArgumentIDAttribute
+
+ // Compare various pairs of attributes for equality.
+ printfn "\nCompare a usage attribute instance to another instance of the same attribute:"
+ printfn $" \"{arrayUsageAttr1}\" == \n \"{arrayUsageAttr2}\"? {arrayUsageAttr1.Equals( arrayUsageAttr2)}"
+
+ printfn "\nCompare a usage attribute to another usage attribute:"
+ printfn $" \"{arrayUsageAttr1}\" == \n \"{listUsageAttr}\"? {arrayUsageAttr1.Equals(listUsageAttr)}"
+
+ printfn "\nCompare an ID attribute instance to another instance of the same attribute:"
+ printfn $" \"{ arrayIDAttr1}\" == \n \"{arrayIDAttr2}\"? {arrayIDAttr1.Equals(arrayIDAttr2)}"
+
+ printfn "\nCompare an ID attribute to another ID attribute:"
+ printfn $" \"{arrayIDAttr1}\" == \n \"{listIDAttr}\"? {arrayIDAttr1.Equals(listIDAttr)}"
+else
+ printfn $"The parameters information could not be retrieved for method {mInfo.Name}."
+
+// The example displays an output similar to the following:
+// Compare a usage attribute instance to another instance of the same attribute:
+// "ArgumentUsageAttribute: Must pass an array here." ==
+// "ArgumentUsageAttribute: Must pass an array here."? True
+//
+// Compare a usage attribute to another usage attribute:
+// "ArgumentUsageAttribute: Must pass an array here." ==
+// "ArgumentUsageAttribute: Can pass param list or array here."? False
+//
+// Compare an ID attribute instance to another instance of the same attribute:
+// "ArgumentIDAttribute.22d1a176-4aca-427b-8230-0c1563e13187" ==
+// "ArgumentIDAttribute.7fa94bba-c290-48e1-a0de-e22f6c1e64f1"? False
+//
+// Compare an ID attribute to another ID attribute:
+// "ArgumentIDAttribute.22d1a176-4aca-427b-8230-0c1563e13187" ==
+// "ArgumentIDAttribute.b9eea70d-9c0f-459e-a984-19c46b6c8789"? False
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/fs.fsproj
new file mode 100644
index 00000000000..07e65f2e2c2
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/fs.fsproj
@@ -0,0 +1,9 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/fs.fsproj
new file mode 100644
index 00000000000..7e48929bb94
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/fs.fsproj
@@ -0,0 +1,10 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrparam.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrparam.fs
new file mode 100644
index 00000000000..3dc01232c97
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrparam.fs
@@ -0,0 +1,80 @@
+module getcustattrparam
+
+//
+open System
+open System.Reflection
+
+//
+// Define a custom parameter attribute that takes a single message argument.
+[]
+type ArgumentUsageAttribute(usageMsg) =
+ inherit Attribute()
+
+ // This is the Message property for the attribute.
+ member val Message = usageMsg with get, set
+//
+
+type BaseClass() =
+ // Assign an ArgumentUsage attribute to the strArray parameter.
+ // Assign a ParamArray attribute to strList.
+ abstract member TestMethod: strArray: string[] * strList: string[] -> unit
+ default _.TestMethod([] strArray, [] strList) = ()
+
+type DerivedClass() =
+ inherit BaseClass()
+
+ // Assign an ArgumentUsage attribute to the strList parameter.
+ // Assign a ParamArray attribute to strList.
+ override _.TestMethod(
+ strArray,
+ []
+ strList) = ()
+
+printfn "This example of Attribute.GetCustomAttribute( ParameterInfo, Type )\ngenerates the following output."
+
+// Get the class type, and then get the MethodInfo object
+// for TestMethod to access its metadata.
+let clsType = typeof
+let mInfo = clsType.GetMethod "TestMethod"
+
+// Iterate through the ParameterInfo array for the method parameters.
+let pInfoArray = mInfo.GetParameters()
+if pInfoArray <> null then
+ for paramInfo in pInfoArray do
+ // See if the ParamArray attribute is defined.
+ let isDef = Attribute.IsDefined(paramInfo, typeof)
+
+ if isDef then
+ printfn $"\nThe ParamArray attribute is defined for \nparameter {paramInfo.Name} of method {mInfo.Name}."
+
+ // See if ParamUsageAttribute is defined.
+ // If so, display a message.
+ let usageAttr =
+ Attribute.GetCustomAttribute(paramInfo, typeof)
+ :?> ArgumentUsageAttribute
+
+ if usageAttr <> null then
+ printfn $"\nThe ArgumentUsage attribute is defined for \nparameter {paramInfo.Name} of method {mInfo.Name}."
+ printfn $"\n The usage message for {paramInfo.Name} is:\n \"{usageAttr.Message}\"."
+else
+ printfn $"The parameters information could not be retrieved for method {mInfo.Name}."
+
+
+// This example of Attribute.GetCustomAttribute(ParameterInfo, Type)
+// generates the following output:
+// The ArgumentUsage attribute is defined for
+// parameter strArray of method TestMethod.
+//
+// The usage message for strArray is:
+// "Must pass an array here.".
+//
+// The ParamArray attribute is defined for
+// parameter strList of method TestMethod.
+//
+// The ArgumentUsage attribute is defined for
+// parameter strList of method TestMethod.
+//
+// The usage message for strList is:
+// "Can pass a parameter list or array here.".
+
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrprminh.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrprminh.fs
new file mode 100644
index 00000000000..7c9e0d36db8
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrprminh.fs
@@ -0,0 +1,106 @@
+module getcustattrprminh
+
+//
+open System
+open System.Reflection
+
+// Define a custom parameter attribute that takes a single message argument.
+[]
+type ArgumentUsageAttribute(usageMsg) =
+ inherit Attribute()
+
+ // This is the Message property for the attribute.
+ member val Message: string = usageMsg
+
+type BaseClass() =
+ // Assign an ArgumentUsage attribute to the strArray parameter.
+ // Assign a ParamArray attribute to strList.
+ abstract member TestMethod: string [] * string[] -> unit
+ default _.TestMethod(
+ []
+ strArray,
+ []
+ strList) = ()
+
+type DerivedClass() =
+ inherit BaseClass()
+ // Assign an ArgumentUsage attribute to the strList parameter.
+ // Assign a ParamArray attribute to strList.
+ override _.TestMethod(
+ strArray,
+ []
+ strList) = ()
+
+let displayParameterAttributes (mInfo: MethodInfo) (pInfoArray: ParameterInfo []) includeInherited =
+ printfn $"""
+Parameter attribute information for method "{mInfo.Name}"
+includes inheritance from base class: {if includeInherited then "Yes" else "No"}."""
+
+ // Display the attribute information for the parameters.
+ for paramInfo in pInfoArray do
+ // See if the ParamArray attribute is defined.
+ let isDef = Attribute.IsDefined(paramInfo, typeof)
+
+ if isDef then
+ printfn $"\n The ParamArray attribute is defined for \n parameter {paramInfo.Name} of method {mInfo.Name}."
+
+ // See if ParamUsageAttribute is defined.
+ // If so, display a message.
+ let usageAttr =
+ Attribute.GetCustomAttribute(paramInfo, typeof, includeInherited)
+ :?> ArgumentUsageAttribute
+
+ if usageAttr <> null then
+ printfn $"\n The ArgumentUsage attribute is defined for \n parameter {paramInfo.Name} of method {mInfo.Name}."
+ printfn $"\n The usage message for {paramInfo.Name} is:\n \"{usageAttr.Message}\"."
+
+printfn "This example of Attribute.GetCustomAttribute(ParameterInfo, Type, Boolean)\ngenerates the following output."
+
+// Get the class type, and then get the MethodInfo object
+// for TestMethod to access its metadata.
+let clsType = typeof
+let mInfo = clsType.GetMethod "TestMethod"
+
+// Iterate through the ParameterInfo array for the method parameters.
+let pInfoArray = mInfo.GetParameters()
+if pInfoArray <> null then
+ displayParameterAttributes mInfo pInfoArray false
+ displayParameterAttributes mInfo pInfoArray true
+else
+ printfn $"The parameters information could not be retrieved for method {mInfo.Name}."
+
+
+// This example of Attribute.GetCustomAttribute( ParameterInfo, Type, Boolean )
+// generates the following output.
+//
+// Parameter attribute information for method "TestMethod"
+// includes inheritance from base class: No.
+//
+// The ParamArray attribute is defined for
+// parameter strList of method TestMethod.
+//
+// The ArgumentUsage attribute is defined for
+// parameter strList of method TestMethod.
+//
+// The usage message for strList is:
+// "Can pass a parameter list or array here.".
+//
+// Parameter attribute information for method "TestMethod"
+// includes inheritance from base class: Yes.
+//
+// The ArgumentUsage attribute is defined for
+// parameter strArray of method TestMethod.
+//
+// The usage message for strArray is:
+// "Must pass an array here.".
+//
+// The ParamArray attribute is defined for
+// parameter strList of method TestMethod.
+//
+// The ArgumentUsage attribute is defined for
+// parameter strList of method TestMethod.
+//
+// The usage message for strList is:
+// "Can pass a parameter list or array here.".
+
+//
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/fs.fsproj b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/fs.fsproj
new file mode 100644
index 00000000000..0608b750631
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/fs.fsproj
@@ -0,0 +1,9 @@
+
+
+ Exe
+ net6.0
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/typeid.fs b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/typeid.fs
new file mode 100644
index 00000000000..96ee311fdd6
--- /dev/null
+++ b/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/typeid.fs
@@ -0,0 +1,95 @@
+//
+module NDP_UE_FS
+
+open System
+
+// Define a custom parameter attribute that takes a single message argument.
+[]
+type ArgumentUsageAttribute(usageMsg) =
+ inherit Attribute()
+
+ let instanceGUID = Guid.NewGuid()
+
+ // This is the Message property for the attribute.
+ member val Message = usageMsg with get, set
+
+ // Override TypeId to provide a unique identifier for the instance.
+ override _.TypeId with get() =
+ box instanceGUID
+
+ // Override ToString() to append the message to what the base generates.
+ override _.ToString() =
+ base.ToString() + ":" + usageMsg
+
+type TestClass() =
+ // Assign an ArgumentUsage attribute to each parameter.
+ // Assign a ParamArray attribute to strList using the params keyword.
+ member _.TestMethod(
+ []
+ strArray: string [],
+ []
+ strList: string []) = ()
+
+let showAttributeTypeIds () =
+ // Get the class type, and then get the MethodInfo object
+ // for TestMethod to access its metadata.
+ let clsType = typeof
+ let mInfo = clsType.GetMethod "TestMethod"
+
+ // There will be two elements in pInfoArray, one for each parameter.
+ let pInfoArray = mInfo.GetParameters()
+ if pInfoArray <> null then
+ // Create an instance of the param array attribute on strList.
+ let listArrayAttr =
+ Attribute.GetCustomAttribute(pInfoArray[1], typeof)
+ :?> ParamArrayAttribute
+
+ // Create an instance of the argument usage attribute on strArray.
+ let arrayUsageAttr1 =
+ Attribute.GetCustomAttribute(pInfoArray[0], typeof)
+ :?> ArgumentUsageAttribute
+
+ // Create another instance of the argument usage attribute
+ // on strArray.
+ let arrayUsageAttr2 =
+ Attribute.GetCustomAttribute(pInfoArray[0], typeof)
+ :?> ArgumentUsageAttribute
+
+ // Create an instance of the argument usage attribute on strList.
+ let listUsageAttr =
+ Attribute.GetCustomAttribute(pInfoArray[1], typeof)
+ :?> ArgumentUsageAttribute
+
+ // Display the attributes and corresponding TypeId values.
+ printfn $"\n\"{listArrayAttr}\" \nTypeId: {listArrayAttr.TypeId}"
+
+ printfn $"\n\"{arrayUsageAttr1}\" \nTypeId: {arrayUsageAttr1.TypeId}"
+ printfn $"\n\"{arrayUsageAttr2}\" \nTypeId: {arrayUsageAttr2.TypeId}"
+ printfn $"\n\"{listUsageAttr}\" \nTypeId: {listUsageAttr.TypeId}"
+ else
+ printfn $"The parameters information could not be retrieved for method {mInfo.Name}."
+
+printfn "This example of the Attribute.TypeId property\ngenerates the following output."
+printfn "\nCreate instances from a derived Attribute class that implements TypeId, \nand then display the attributes and corresponding TypeId values:"
+
+showAttributeTypeIds ()
+
+// This example of the Attribute.TypeId property
+// generates output similar to the following:
+//
+// Create instances from a derived Attribute class that implements TypeId,
+// and then display the attributes and corresponding TypeId values:
+//
+// "System.ParamArrayAttribute"
+// TypeId: System.ParamArrayAttribute
+//
+// "NDP_UE_FS+ArgumentUsageAttribute:Must pass an array here."
+// TypeId: d03a23f4-2536-4478-920f-8b0426dec7f1
+//
+// "NDP_UE_FS+ArgumentUsageAttribute:Must pass an array here."
+// TypeId: a1b412e8-3047-49fa-8d03-7660d37ef718
+//
+// "NDP_UE_FS+ArgumentUsageAttribute:Can pass a param list or array here."
+// TypeId: 7ac2bf61-0327-48d6-a07e-eb9aaf3dd45e
+
+//
diff --git a/xml/System/Attribute.xml b/xml/System/Attribute.xml
index 0aad4f9397b..e65552ec9a5 100644
--- a/xml/System/Attribute.xml
+++ b/xml/System/Attribute.xml
@@ -89,6 +89,7 @@
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/AnimalAttributes/CPP/customattribute.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/AnimalAttributes/CS/customattribute.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/AnimalAttributes/VB/customattribute.vb" id="Snippet1":::
]]>
@@ -145,6 +146,7 @@
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrparam.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CS/getcustattrparam.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrparam.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/VB/getcustattrparam.vb" id="Snippet2":::
]]>
@@ -215,6 +217,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.Equals/CPP/equals.cpp":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Attribute.Equals/CS/equals.cs" interactive="try-dotnet":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/equals.fs":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.Equals/VB/equals.vb":::
]]>
@@ -288,6 +291,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id1.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id1.vb" id="Snippet1":::
]]>
@@ -356,6 +360,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet4":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id4.cs" interactive="try-dotnet" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id4.vb" id="Snippet4":::
]]>
@@ -419,6 +424,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id2.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id2.vb" id="Snippet2":::
]]>
@@ -484,6 +490,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrparam.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CS/getcustattrparam.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrparam.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/VB/getcustattrparam.vb" id="Snippet1":::
]]>
@@ -554,6 +561,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id1.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id1.vb" id="Snippet1":::
]]>
@@ -623,6 +631,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet4":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id4.cs" interactive="try-dotnet" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id4.vb" id="Snippet4":::
]]>
@@ -688,6 +697,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id2.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id2.vb" id="Snippet2":::
]]>
@@ -755,6 +765,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrprminh.cpp" id="Snippet3":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CS/getcustattrprminh.cs" interactive="try-dotnet" id="Snippet3":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrprminh.fs" id="Snippet3":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/VB/getcustattrprminh.vb" id="Snippet3":::
]]>
@@ -830,6 +841,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca1.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca1.vb" id="Snippet1":::
]]>
@@ -892,6 +904,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet4":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca4.cs" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca4.vb" id="Snippet4":::
]]>
@@ -949,6 +962,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca2.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca2.vb" id="Snippet2":::
]]>
@@ -1008,6 +1022,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet5":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca5.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs" id="Snippet5":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca5.vb" id="Snippet5":::
]]>
@@ -1072,6 +1087,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca1.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca1.vb" id="Snippet1":::
]]>
@@ -1135,6 +1151,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca1.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca1.vb" id="Snippet1":::
]]>
@@ -1201,6 +1218,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet4":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca4.cs" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca4.vb" id="Snippet4":::
]]>
@@ -1265,6 +1283,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca2.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca2.vb" id="Snippet2":::
]]>
@@ -1321,6 +1340,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca2.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca2.vb" id="Snippet2":::
]]>
@@ -1390,6 +1410,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet5":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca5.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs" id="Snippet5":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca5.vb" id="Snippet5":::
]]>
@@ -1453,6 +1474,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet5":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca5.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs" id="Snippet5":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca5.vb" id="Snippet5":::
]]>
@@ -1521,6 +1543,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca1.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca1.vb" id="Snippet1":::
]]>
@@ -1594,6 +1617,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet4":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca4.cs" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca4.vb" id="Snippet4":::
]]>
@@ -1662,6 +1686,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca2.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca2.vb" id="Snippet2":::
]]>
@@ -1733,6 +1758,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet5":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca5.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs" id="Snippet5":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca5.vb" id="Snippet5":::
]]>
@@ -1809,6 +1835,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet4":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetCustomAttributes/CS/ca4.cs" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca4.vb" id="Snippet4":::
]]>
@@ -1874,6 +1901,7 @@ When implementing your own class derived from , you can o
The following code example illustrates the use of in the context of .
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/GetHashCode/CS/hashcode.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/GetHashCode/FS/hashcode.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/GetHashCode/VB/hashcode.vb" id="Snippet1":::
]]>
@@ -1931,6 +1959,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefaultAttribute/CPP/defattr.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefaultAttribute/CS/defattr.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/defattr.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefaultAttribute/VB/defattr.vb" id="Snippet1":::
]]>
@@ -2003,6 +2032,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id1.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id1.vb" id="Snippet1":::
]]>
@@ -2070,6 +2100,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet4":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id4.cs" interactive="try-dotnet" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id4.vb" id="Snippet4":::
]]>
@@ -2136,6 +2167,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id2.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id2.vb" id="Snippet2":::
]]>
@@ -2200,6 +2232,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet5":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id5.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id5.fs" id="Snippet5":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id5.vb" id="Snippet5":::
]]>
@@ -2268,6 +2301,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id1.cs" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id1.vb" id="Snippet1":::
]]>
@@ -2336,6 +2370,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet4":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id4.cs" interactive="try-dotnet" id="Snippet4":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs" id="Snippet4":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id4.vb" id="Snippet4":::
]]>
@@ -2410,6 +2445,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet2":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id2.cs" id="Snippet2":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs" id="Snippet2":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id2.vb" id="Snippet2":::
]]>
@@ -2471,6 +2507,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet5":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/IsDefined/CS/id5.cs" interactive="try-dotnet" id="Snippet5":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id5.fs" id="Snippet5":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id5.vb" id="Snippet5":::
]]>
@@ -2540,6 +2577,7 @@ When implementing your own class derived from , you can o
The following example illustrates the use of to create a custom comparison method for attribute values. If defines an `AuthorsAttribute` that internally contains a `List` that stores authors' names. Because the names can occur in any order in the list, it overrides the method to compare author names regardless of their position in the list. Note the method, which performs a test for value equality, returns different results from the method.
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR/Match/CS/match.cs" interactive="try-dotnet":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR/Match/FS/match.fs":::
[!code-vb[Match#1](~/samples/snippets/visualbasic/VS_Snippets_CLR/Match/VB/match.vb)]
]]>
@@ -2791,6 +2829,7 @@ When implementing your own class derived from , you can o
:::code language="cpp" source="~/samples/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.TypeId/CPP/typeid.cpp" id="Snippet1":::
:::code language="csharp" source="~/samples/snippets/csharp/VS_Snippets_CLR_System/system.Attribute.TypeId/CS/typeid.cs" interactive="try-dotnet" id="Snippet1":::
+ :::code language="fsharp" source="~/samples/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/typeid.fs" id="Snippet1":::
:::code language="vb" source="~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.TypeId/VB/typeid.vb" id="Snippet1":::
]]>
From bbc4e2202fcb38b8d6132c6d28e134e1016e304b Mon Sep 17 00:00:00 2001
From: albert-du <52804499+albert-du@users.noreply.github.com>
Date: Tue, 4 Jan 2022 07:42:52 -0800
Subject: [PATCH 2/3] Update customattribute.fs
---
.../VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs b/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs
index f7cc1f7b6f7..8bcea9f284b 100644
--- a/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs
@@ -24,9 +24,9 @@ type AnimalTypeTestClass() =
member _.BirdMethod() = ()
let testClass = AnimalTypeTestClass()
-let type' = testClass.GetType()
+let clsType = testClass.GetType()
// Iterate through all the methods of the class.
-for mInfo in type'.GetMethods() do
+for mInfo in clsType.GetMethods() do
// Iterate through all the Attributes for each method.
for attr in Attribute.GetCustomAttributes mInfo do
// Check for the AnimalType attribute.
From e4f2459eb76bbe8d0b73ff923f972052c10dc8a6 Mon Sep 17 00:00:00 2001
From: albert-du <52804499+albert-du@users.noreply.github.com>
Date: Wed, 5 Jan 2022 07:04:00 -0800
Subject: [PATCH 3/3] Update ca2.fs
module' -> ilmodule
---
.../fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs
index ec32d976c1f..10bde4c5362 100644
--- a/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs
+++ b/samples/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs
@@ -15,18 +15,18 @@ do ()
type DemoClass = class end
// Get the Module type to access its metadata.
-let module' = typeof.Module
+let ilmodule = typeof.Module
// Iterate through all the attributes for the module.
-for attr in Attribute.GetCustomAttributes module' do
+for attr in Attribute.GetCustomAttributes ilmodule do
match attr with
// Check for the Description attribute.
| :? DescriptionAttribute as attr ->
- printfn $"Module {module'.Name} has the description \"{attr.Description}\"."
+ printfn $"Module {ilmodule.Name} has the description \"{attr.Description}\"."
// Check for the CLSCompliant attribute.
| :? CLSCompliantAttribute as attr ->
- printfn $"""Module {module'.Name} {if attr.IsCompliant then "is" else "is not"} CLSCompliant."""
+ printfn $"""Module {ilmodule.Name} {if attr.IsCompliant then "is" else "is not"} CLSCompliant."""
| _ -> ()
// Output: