Skip to content

Commit c243063

Browse files
author
Colin Robertson
authored
Clean up Managed Extensions links and examples (MicrosoftDocs#81)
1 parent 92372c9 commit c243063

130 files changed

Lines changed: 139 additions & 2472 deletions

File tree

Some content is hidden

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

‎docs/build/reference/doc-process-documentation-comments-c-cpp.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ Causes the compiler to process documentation comments in source code files and t
5757

5858
You can add documentation comments to your source code files. For more information, see [Recommended Tags for Documentation Comments](../../ide/recommended-tags-for-documentation-comments-visual-cpp.md).
5959

60-
**/doc** is not compatible with **/clr:oldSyntax**. See [/clr (Common Language Runtime Compilation)](../../build/reference/clr-common-language-runtime-compilation.md) for more information.
61-
6260
To use the generated .xml file with IntelliSense, make the file name of the .xml file the same as the assembly that you want to support and put the .xml file is in the same directory as the assembly. When the assembly is referenced in the Visual Studio project, the .xml file is also found. For more information, see [Using IntelliSense](/visualstudio/ide/using-intellisense) and [Supplying XML Code Comments](/visualstudio/ide/supplying-xml-code-comments).
6361

6462
### To set this compiler option in the Visual Studio development environment

‎docs/cpp/clrcall.md‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ translation.priority.ht:
5454

5555
`__clrcall` function pointers are only meant to be used in the application domain in which they were created. Instead of passing `__clrcall` function pointers across application domains, use <xref:System.CrossAppDomainDelegate>. For more information, see [Application Domains and Visual C++](../dotnet/application-domains-and-visual-cpp.md).
5656

57-
## Example
58-
59-
```
60-
// clrcall.cpp
61-
// compile with: /clr:oldSyntax /LD
62-
void __clrcall Test1( ) {}
63-
void (__clrcall *fpTest1)( ) = &Test1;
64-
```
65-
6657
## Example
6758
Note that when a function is declared with `__clrcall`, code will be generated when needed; for example, when function is called.
6859

‎docs/cpp/destructors-cpp.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ translation.priority.ht:
4040
# Destructors (C++)
4141
"Destructor" functions are the inverse of constructor functions. They are called when objects are destroyed (deallocated). Designate a function as a class's destructor by preceding the class name with a tilde (`~`). For example, the destructor for class `String` is declared: `~String()`.
4242

43-
In a /clr compilation, the destructor has a special role in releasing managed and unmanaged resources. See [Destructors and Finalizers in Visual C++](../misc/destructors-and-finalizers-in-visual-cpp.md) for more information.
43+
In a /clr compilation, the destructor has a special role in releasing managed and unmanaged resources. See [Destructors and finalizers in How to: Define and consume classes and structs (C++/CLI)](../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers) for more information.
4444

4545
The destructor is commonly used to "clean up" when an object is no longer necessary. Consider the following declaration of a `String` class:
4646

‎docs/cpp/event.md‎

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -146,38 +146,6 @@ public:
146146
};
147147
```
148148

149-
## Example: Managed Events
150-
151-
```
152-
// EventHandling_Managed_Event.cpp
153-
// compile with: /clr:oldSyntax /c
154-
using namespace System;
155-
[event_source(managed)]
156-
public __gc class CPSource {
157-
158-
public:
159-
__event void MyEvent(Int16 nValue);
160-
};
161-
```
162-
163-
When applying an attribute to an event, you can specify that the attribute apply to either the generated methods or to the Invoke method of the generated delegate. The default (`event:`) is to apply the attribute to the event.
164-
165-
```
166-
// EventHandling_Managed_Event_2.cpp
167-
// compile with: /clr:oldSyntax /c
168-
using namespace System;
169-
[attribute(All, AllowMultiple=true)]
170-
public __gc class Attr {};
171-
172-
public __delegate void D();
173-
174-
public __gc class X {
175-
public:
176-
[method:Attr] __event D* E;
177-
[returnvalue:Attr] __event void noE();
178-
};
179-
```
180-
181149
## See Also
182150
[Keywords](../cpp/keywords-cpp.md)
183151
[Event Handling](../cpp/event-handling.md)

‎docs/cpp/keywords-cpp.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ Keywords are predefined reserved identifiers that have special meanings. They ca
9191
|[__assume](../intrinsics/assume.md)|[__based](../cpp/based-pointers-cpp.md)|[__box](../misc/box.md) <sup>2</sup>|
9292
|[__cdecl](../cpp/cdecl.md)|[__declspec](../cpp/declspec.md)|[__delegate](../misc/delegate.md) <sup>2</sup>|
9393
|[__event](../cpp/event.md)|[__except](../cpp/try-except-statement.md)|[__fastcall](../cpp/fastcall.md)|
94-
|[__finally](../cpp/try-finally-statement.md)|[__forceinline](../cpp/inline-functions-cpp.md)|[__gc](../misc/gc.md) <sup>2</sup>|
94+
|[__finally](../cpp/try-finally-statement.md)|[__forceinline](../cpp/inline-functions-cpp.md)|[__gc](../dotnet/declaration-of-a-clr-reference-class-object.md) <sup>2</sup>|
9595
|[__hook](../cpp/hook.md) <sup>3</sup>|[__identifier](../windows/identifier-cpp-cli.md)|[__if_exists](../cpp/if-exists-statement.md)|
9696
|[__if_not_exists](../cpp/if-not-exists-statement.md)|[__inline](../cpp/inline-functions-cpp.md)|[__int16](../cpp/int8-int16-int32-int64.md)|
9797
|[__int32](../cpp/int8-int16-int32-int64.md)|[__int64](../cpp/int8-int16-int32-int64.md)|[__int8](../cpp/int8-int16-int32-int64.md)|
9898
|[__interface](../cpp/interface.md)|[__leave](../cpp/try-finally-statement.md)|[__m128](../cpp/m128.md)|
9999
|[__m128d](../cpp/m128d.md)|[__m128i](../cpp/m128i.md)|[__m64](../cpp/m64.md)|
100-
|[__multiple_inheritance](../cpp/inheritance-keywords.md)|[__nogc](../misc/nogc.md) <sup>2</sup>|[__noop](../intrinsics/noop.md)|
100+
|[__multiple_inheritance](../cpp/inheritance-keywords.md)|[__nogc](../dotnet/declaration-of-a-clr-reference-class-object.md) <sup>2</sup>|[__noop](../intrinsics/noop.md)|
101101
|[__pin](../misc/pin.md) <sup>2</sup>|[__property](../misc/property.md) <sup>2</sup>|[__raise](../cpp/raise.md)|
102102
|[__sealed](../misc/sealed.md) <sup>2</sup>|[__single_inheritance](../cpp/inheritance-keywords.md)|[__stdcall](../cpp/stdcall.md)|
103103
|[__super](../cpp/super.md)|[__thiscall](../cpp/thiscall.md)|[__try/\__except](../cpp/try-except-statement.md), [__try/\__finally](../cpp/try-finally-statement.md)|

‎docs/cpp/thiscall.md‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,6 @@ translation.priority.mt:
5454

5555
For non-static class functions, if the function is defined out-of-line, the calling convention modifier does not have to be specified on the out-of-line definition. That is, for class non-static member methods, the calling convention specified during declaration is assumed at the point of definition.
5656

57-
## Example
58-
59-
```
60-
// thiscall_cc.cpp
61-
// compile with: /c /clr:oldSyntax
62-
struct CMyClass {
63-
void __thiscall mymethod();
64-
void __clrcall mymethod2();
65-
};
66-
```
67-
6857
## END Microsoft Specific
6958

7059
## See Also

‎docs/dotnet/changes-in-destructor-semantics.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,4 @@ public:
208208

209209
## See Also
210210
[Managed Types (C++/CL)](../dotnet/managed-types-cpp-cl.md)
211-
[Destructors and Finalizers in Visual C++](../misc/destructors-and-finalizers-in-visual-cpp.md)
211+
[Destructors and finalizers in How to: Define and consume classes and structs (C++/CLI)](../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers)

‎docs/dotnet/cpp-stack-semantics-for-reference-types.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Prior to Visual C++ 2005, an instance of a reference type could only be created
4646

4747
The compiler will not generate a default assignment operator for a reference type. An assignment operator allows you to create an object using stack semantics and initialize it with an existing object created using stack semantics. An assignment operator for a reference type has a signature of the following form: `void operator=( R% ){}`.
4848

49-
If your type's destructor releases critical resources and you use stack semantics for reference types, you do not need to explicitly call the destructor (or call `delete`). For more information on destructors in reference types, see [Destructors and Finalizers in Visual C++](../misc/destructors-and-finalizers-in-visual-cpp.md).
49+
If your type's destructor releases critical resources and you use stack semantics for reference types, you do not need to explicitly call the destructor (or call `delete`). For more information on destructors in reference types, see [Destructors and finalizers in How to: Define and consume classes and structs (C++/CLI)](../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Destructors_and_finalizers).
5050

5151
A compiler-generated assignment operator will follow the usual standard C++ rules with the following additions:
5252

‎docs/dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md‎

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ int main() {
572572
## <a name="BKMK_Hide_by_signature_functions"></a> Hide-by-signature functions
573573
In standard C++, a function in a base class is hidden by a function that has the same name in a derived class, even if the derived-class function does not have the same number or kind of parameters. This is referred to as *hide-by-name* semantics. In a reference type, a function in a base class can only be hidden by a function in a derived class if both the name and the parameter list are the same. This is known as *hide-by-signature* semantics.
574574

575-
A class is considered a hide-by-signature class when all of its functions are marked in the metadata as `hidebysig`. By default, all classes that are created under **/clr** have `hidebysig` functions. However, a class that's compiled by using **/clr:oldSyntax** does not have `hidebysig` functions; instead, they are hide-by-name functions. When a class has `hidebysig` functions, the compiler doesn't hide functions by name in any direct base classes, but if the compiler encounters a hide-by-name class in an inheritance chain, it continues that hide-by-name behavior.
575+
A class is considered a hide-by-signature class when all of its functions are marked in the metadata as `hidebysig`. By default, all classes that are created under **/clr** have `hidebysig` functions. When a class has `hidebysig` functions, the compiler doesn't hide functions by name in any direct base classes, but if the compiler encounters a hide-by-name class in an inheritance chain, it continues that hide-by-name behavior.
576576

577577
Under hide-by-signature semantics, when a function is called on an object, the compiler identifies the most derived class that contains a function that could satisfy the function call. If there is only one function in the class that could satisfy the call, the compiler calls that function. If there is more than one function in the class that could satisfy the call, the compiler uses overload resolution rules to determine which function to call. For more information about overload rules, see [Function Overloading](../cpp/function-overloading.md).
578578

@@ -677,48 +677,6 @@ int main() {
677677
```Output
678678
Derived::Test4
679679
97
680-
```
681-
682-
The following sample defines a component that's compiled by using **/clr:oldSyntax**. Classes that are defined by using Managed Extensions for C++ have hide-by-name member functions.
683-
684-
```
685-
686-
// compile with: /clr:oldSyntax /LD
687-
using namespace System;
688-
public __gc struct Base0 {
689-
void Test() {
690-
Console::WriteLine("in Base0::Test");
691-
}
692-
};
693-
694-
public __gc struct Base1 : public Base0 {
695-
void Test(int i) {
696-
Console::WriteLine("in Base1::Test");
697-
}
698-
};
699-
```
700-
701-
The next sample consumes the component that's built in the previous sample. Notice how hide-by-signature functionality is not applied to base classes of types that are compiled by using **/clr:oldSyntax**.
702-
703-
```
704-
705-
// compile with: /clr:oldSyntax /LD
706-
// compile with: /clr
707-
using namespace System;
708-
#using "hide_by_signature_4.dll"
709-
710-
ref struct Derived : public Base1 {
711-
void Test(int i, int j) {
712-
Console::WriteLine("Derived::Test");
713-
}
714-
};
715-
716-
int main() {
717-
Derived ^ t = gcnew Derived;
718-
t->Test(8, 8); // OK
719-
t->Test(8); // OK
720-
t->Test(); // C2661
721-
}
722680
```
723681

724682
## <a name="BKMK_Copy_constructors"></a> Copy constructors

‎docs/dotnet/how-to-migrate-to-clr.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ This topic discusses issues that arise when compiling native code with **/clr**
6565
Projects previous built with Visual C++ 2003 should also first be compiled without **/clr** as Visual Studio now has increased ANSI/ISO compliance and some breaking changes. The change that is likely to require the most attention is [Security Features in the CRT](../c-runtime-library/security-features-in-the-crt.md). Code that uses the CRT is very likely to produce deprecation warnings. These warnings can be suppressed, but migrating to the new [Security-Enhanced Versions of CRT Functions](../c-runtime-library/security-enhanced-versions-of-crt-functions.md) is preferred, as they provide better security and may reveal security issues in your code.
6666
6767
### Upgrading from Managed Extensions for C++
68-
Projects built with Visual C++ .NET or Visual C++ 2003 that used Managed Extensions for C++ will require at least one change to project settings, as these extensions are now deprecated. As a result, code written with Managed Extensions for C++ won't compile under **/clr**. Use **/clr:oldSyntax** instead.
68+
Projects built with Visual C++ .NET or Visual C++ 2003 that used Managed Extensions for C++ must be rewritten to use the new syntax, as these extensions are no longer supported. Code written with Managed Extensions for C++ won't compile under **/clr**.
6969
7070
## Convert C Code to C++
7171
Although Visual Studio will compile C files, it is necessary to convert them to C++ for a **/clr** compilation. The actual filename doesn't have to be changed; you can use **/Tp** (see [/Tc, /Tp, /TC, /TP (Specify Source File Type)](../build/reference/tc-tp-tc-tp-specify-source-file-type.md).) Note that although C++ source code files are required for **/clr**, it is not necessary to re-factor your code to use object-oriented paradigms.

0 commit comments

Comments
 (0)