Skip to content

Commit b9f706a

Browse files
authored
Delete unnecessary C++/CLI snippets (#45884)
1 parent 7c9fecf commit b9f706a

File tree

125 files changed

+1513
-8766
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1513
-8766
lines changed

Diff for: docs/framework/interop/marshalling-classes-structures-and-unions.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
title: "Marshalling Classes, Structures, and Unions"
33
description: Review how to marshal classes, structures, and unions. View samples of marshalling classes, structures with nested structures, arrays of structures, and unions.
44
ms.date: "03/30/2017"
5-
dev_langs:
5+
dev_langs:
66
- "csharp"
77
- "vb"
88
- "cpp"
9-
helpviewer_keywords:
9+
helpviewer_keywords:
1010
- "data marshalling, classes"
1111
- "marshaling, unions"
1212
- "marshaling, structures"
@@ -42,8 +42,8 @@ The following table lists marshalling options for classes, structures, and union
4242

4343
## Structures sample
4444

45-
This sample demonstrates how to pass a structure that points to a second structure, pass a structure with an embedded structure, and pass a structure with an embedded array.
46-
45+
This sample demonstrates how to pass a structure that points to a second structure, pass a structure with an embedded structure, and pass a structure with an embedded array.
46+
4747
The Structs sample uses the following unmanaged functions, shown with their original function declaration:
4848

4949
- **TestStructInStruct** exported from PinvokeLib.dll.
@@ -222,7 +222,7 @@ The `NativeMethods` class contains the prototypes for the `TestUnion` and `TestU
222222

223223
In some scenarios, `struct` and `union` layouts can differ depending on the targeted platform. For example, consider the [`STRRET`](/windows/win32/api/shtypes/ns-shtypes-strret) type when defined in a COM scenario:
224224

225-
```c++
225+
```cpp
226226
#include <pshpack8.h> /* Defines the packing of the struct */
227227
typedef struct _STRRET
228228
{

Diff for: docs/fundamentals/reflection/accessing-custom-attributes.md

-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ ms.date: 03/27/2024
55
dev_langs:
66
- "csharp"
77
- "vb"
8-
- "cpp"
98
helpviewer_keywords:
109
- "custom attributes, accessibility"
1110
- "attributes [.NET], accessing"
1211
- "reflection, custom attributes"
13-
ms.assetid: 1d8e3398-00d8-47d5-a084-214f9859d3d7
1412
---
1513
# Access custom attributes
1614

@@ -61,7 +59,6 @@ The custom attribute reflection model could leak instances of user-defined types
6159

6260
The following example demonstrates the basic way of using reflection to get access to custom attributes.
6361

64-
[!code-cpp[CustomAttributeData#2](../../../samples/snippets/cpp/VS_Snippets_CLR/CustomAttributeData/CPP/source2.cpp#2)]
6562
[!code-csharp[CustomAttributeData#2](../../../samples/snippets/csharp/VS_Snippets_CLR/CustomAttributeData/CS/source2.cs#2)]
6663
[!code-vb[CustomAttributeData#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/CustomAttributeData/VB/source2.vb#2)]
6764

Diff for: docs/fundamentals/reflection/dynamically-loading-and-using-types.md

-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ ms.date: "03/30/2017"
55
dev_langs:
66
- "csharp"
77
- "vb"
8-
- "cpp"
98
helpviewer_keywords:
109
- "late binding, about late binding"
1110
- "early binding"
1211
- "dynamically loading and using types"
1312
- "implicit late binding"
1413
- "reflection, dynamically using types"
15-
ms.assetid: db985bec-5942-40ec-b13a-771ae98623dc
1614
---
1715
# Dynamically load and use types
1816

@@ -44,7 +42,6 @@ Using custom binding, you can load an assembly at run time, obtain information a
4442

4543
The following example demonstrates a simple custom binder that provides no argument type conversion. Code for `Simple_Type.dll` precedes the main example. Be sure to build `Simple_Type.dll` and then include a reference to it in the project at build time.
4644

47-
[!code-cpp[Conceptual.Types.Dynamic#1](../../../samples/snippets/cpp/VS_Snippets_CLR/conceptual.types.dynamic/cpp/source1.cpp#1)]
4845
[!code-csharp[Conceptual.Types.Dynamic#1](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.types.dynamic/cs/source1.cs#1)]
4946
[!code-vb[Conceptual.Types.Dynamic#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.types.dynamic/vb/source1.vb#1)]
5047

@@ -54,7 +51,6 @@ Use <xref:System.Type.InvokeMember%2A?displayProperty=nameWithType> to invoke a
5451

5552
The following example shows the three possible combinations of argument coercion (type conversion) and member selection. In Case 1, no argument coercion or member selection is needed. In Case 2, only member selection is needed. In Case 3, only argument coercion is needed.
5653

57-
[!code-cpp[Conceptual.Types.Dynamic#2](../../../samples/snippets/cpp/VS_Snippets_CLR/conceptual.types.dynamic/cpp/source2.cpp#2)]
5854
[!code-csharp[Conceptual.Types.Dynamic#2](../../../samples/snippets/csharp/VS_Snippets_CLR/conceptual.types.dynamic/cs/source2.cs#2)]
5955
[!code-vb[Conceptual.Types.Dynamic#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/conceptual.types.dynamic/vb/source2.vb#2)]
6056

Diff for: docs/fundamentals/reflection/get-type-member-information.md

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ ms.topic: how-to
66
helpviewer_keywords:
77
- "reflection, obtaining member information"
88
- "types [.NET], obtaining member information from"
9-
ms.assetid: 348ae651-ccda-4f13-8eda-19e8337e9438
109
dev_langs:
11-
- "cpp"
1210
- "csharp"
1311
- "vb"
1412
---
@@ -20,7 +18,6 @@ The <xref:System.Reflection> namespace contains many methods for obtaining infor
2018

2119
The following example obtains type and member information by using reflection:
2220

23-
[!code-cpp[Get type members](../../../samples/snippets/standard/reflection/memberinfo/gettypemembers.cpp)]
2421
[!code-csharp[Get type members](../../../samples/snippets/standard/reflection/memberinfo/gettypemembers.cs)]
2522
[!code-vb[Get type members](../../../samples/snippets/standard/reflection/memberinfo/gettypemembers.vb)]
2623

Diff for: docs/fundamentals/reflection/how-to-define-a-generic-type-with-reflection-emit.md

-15
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ ms.date: 03/27/2024
55
dev_langs:
66
- "csharp"
77
- "vb"
8-
- "cpp"
98
helpviewer_keywords:
109
- "generics [.NET], reflection emit"
1110
- "generics [.NET], dynamic types"
1211
- "reflection emit, generic types"
13-
ms.assetid: 07d5f01a-7b5b-40ea-9b15-f21561098fe4
1412
---
1513
# How to: Define a generic type with reflection emit
1614

@@ -23,51 +21,43 @@ This article shows how to create a simple generic type with two type parameters,
2321

2422
1. Define a dynamic assembly named `GenericEmitExample1`. In this example, the assembly is executed and saved to disk, so <xref:System.Reflection.Emit.AssemblyBuilderAccess.RunAndSave?displayProperty=nameWithType> is specified.
2523

26-
[!code-cpp[EmitGenericType#2](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#2)]
2724
[!code-csharp[EmitGenericType#2](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#2)]
2825
[!code-vb[EmitGenericType#2](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#2)]
2926

3027
1. Define a dynamic module. An assembly is made up of executable modules. For a single-module assembly, the module name is the same as the assembly name, and the file name is the module name plus an extension.
3128

32-
[!code-cpp[EmitGenericType#3](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#3)]
3329
[!code-csharp[EmitGenericType#3](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#3)]
3430
[!code-vb[EmitGenericType#3](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#3)]
3531

3632
1. Define a class. In this example, the class is named `Sample`.
3733

38-
[!code-cpp[EmitGenericType#4](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#4)]
3934
[!code-csharp[EmitGenericType#4](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#4)]
4035
[!code-vb[EmitGenericType#4](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#4)]
4136

4237
1. Define the generic type parameters of `Sample` by passing an array of strings containing the names of the parameters to the <xref:System.Reflection.Emit.TypeBuilder.DefineGenericParameters%2A?displayProperty=nameWithType> method. This makes the class a generic type. The return value is an array of <xref:System.Reflection.Emit.GenericTypeParameterBuilder> objects representing the type parameters, which can be used in your emitted code.
4338

4439
In the following code, `Sample` becomes a generic type with type parameters `TFirst` and `TSecond`. To make the code easier to read, each <xref:System.Reflection.Emit.GenericTypeParameterBuilder> is placed in a variable with the same name as the type parameter.
4540

46-
[!code-cpp[EmitGenericType#5](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#5)]
4741
[!code-csharp[EmitGenericType#5](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#5)]
4842
[!code-vb[EmitGenericType#5](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#5)]
4943

5044
1. Add special constraints to the type parameters. In this example, type parameter `TFirst` is constrained to types that have parameterless constructors, and to reference types.
5145

52-
[!code-cpp[EmitGenericType#6](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#6)]
5346
[!code-csharp[EmitGenericType#6](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#6)]
5447
[!code-vb[EmitGenericType#6](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#6)]
5548

5649
1. Optionally add class and interface constraints to the type parameters. In this example, type parameter `TFirst` is constrained to types that derive from the base class represented by the <xref:System.Type> object contained in the variable `baseType`, and that implement the interfaces whose types are contained in the variables `interfaceA` and `interfaceB`. See the code example for the declaration and assignment of these variables.
5750

58-
[!code-cpp[EmitGenericType#7](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#7)]
5951
[!code-csharp[EmitGenericType#7](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#7)]
6052
[!code-vb[EmitGenericType#7](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#7)]
6153

6254
1. Define a field. In this example, the type of the field is specified by type parameter `TFirst`. <xref:System.Reflection.Emit.GenericTypeParameterBuilder> derives from <xref:System.Type>, so you can use generic type parameters anywhere a type can be used.
6355

64-
[!code-cpp[EmitGenericType#21](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#21)]
6556
[!code-csharp[EmitGenericType#21](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#21)]
6657
[!code-vb[EmitGenericType#21](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#21)]
6758

6859
1. Define a method that uses the type parameters of the generic type. Note that such methods are not generic unless they have their own type parameter lists. The following code defines a `static` method (`Shared` in Visual Basic) that takes an array of `TFirst` and returns a `List<TFirst>` (`List(Of TFirst)` in Visual Basic) containing all the elements of the array. To define this method, it is necessary to create the type `List<TFirst>` by calling <xref:System.Type.MakeGenericType%2A> on the generic type definition, `List<T>`. (The `T` is omitted when you use the `typeof` operator (`GetType` in Visual Basic) to get the generic type definition.) The parameter type is created by using the <xref:System.Type.MakeArrayType%2A> method.
6960

70-
[!code-cpp[EmitGenericType#22](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#22)]
7161
[!code-csharp[EmitGenericType#22](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#22)]
7262
[!code-vb[EmitGenericType#22](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#22)]
7363

@@ -82,25 +72,21 @@ This article shows how to create a simple generic type with two type parameters,
8272
8373
Now it is possible to get the constructor of `List<T>` by calling <xref:System.Type.GetConstructor%2A> on the generic type definition. To convert this constructor to the corresponding constructor of `List<TFirst>`, pass `List<TFirst>` and the constructor from `List<T>` to the static <xref:System.Reflection.Emit.TypeBuilder.GetConstructor%28System.Type%2CSystem.Reflection.ConstructorInfo%29?displayProperty=nameWithType> method.
8474

85-
[!code-cpp[EmitGenericType#23](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#23)]
8675
[!code-csharp[EmitGenericType#23](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#23)]
8776
[!code-vb[EmitGenericType#23](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#23)]
8877

8978
1. Create the type and save the file.
9079

91-
[!code-cpp[EmitGenericType#8](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#8)]
9280
[!code-csharp[EmitGenericType#8](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#8)]
9381
[!code-vb[EmitGenericType#8](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#8)]
9482

9583
1. Invoke the method. `ExampleMethod` is not generic, but the type it belongs to is generic, so to get a <xref:System.Reflection.MethodInfo> that can be invoked, it's necessary to create a constructed type from the type definition for `Sample`. The constructed type uses the `Example` class, which satisfies the constraints on `TFirst` because it is a reference type and has a default parameterless constructor, and the `ExampleDerived` class which satisfies the constraints on `TSecond`. (The code for `ExampleDerived` can be found in the example code section.) These two types are passed to <xref:System.Type.MakeGenericType%2A> to create the constructed type. The <xref:System.Reflection.MethodInfo> is then obtained using the <xref:System.Type.GetMethod%2A> method.
9684

97-
[!code-cpp[EmitGenericType#9](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#9)]
9885
[!code-csharp[EmitGenericType#9](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#9)]
9986
[!code-vb[EmitGenericType#9](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#9)]
10087

10188
1. The following code creates an array of `Example` objects, places that array in an array of type <xref:System.Object> representing the arguments of the method to be invoked, and passes them to the <xref:System.Reflection.MethodBase.Invoke%28System.Object%2CSystem.Object%5B%5D%29> method. The first argument of the <xref:System.Reflection.MethodBase.Invoke%2A> method is a null reference because the method is `static`.
10289

103-
[!code-cpp[EmitGenericType#10](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#10)]
10490
[!code-csharp[EmitGenericType#10](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#10)]
10591
[!code-vb[EmitGenericType#10](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#10)]
10692

@@ -118,7 +104,6 @@ The program includes a method that lists information about a generic type, and a
118104

119105
The program saves the finished module to disk as `GenericEmitExample1.dll`, so you can open it with the [Ildasm.exe (IL Disassembler)](../../framework/tools/ildasm-exe-il-disassembler.md) and examine the CIL for the `Sample` class.
120106

121-
[!code-cpp[EmitGenericType#1](../../../samples/snippets/cpp/VS_Snippets_CLR/EmitGenericType/CPP/source.cpp#1)]
122107
[!code-csharp[EmitGenericType#1](../../../samples/snippets/csharp/VS_Snippets_CLR/EmitGenericType/CS/source.cs#1)]
123108
[!code-vb[EmitGenericType#1](../../../samples/snippets/visualbasic/VS_Snippets_CLR/EmitGenericType/VB/source.vb#1)]
124109

0 commit comments

Comments
 (0)