.NET: Microsoft Technologies based on the .NET software framework. Runtime: An environment required to run apps that aren't compiled to machine language.
Code analysis for C++/CLI
Hi! I have a question regarding the code analysis of C++/CLI using the Mixed Recommended Rules rule set.
Are the rules for managed code (e.g. CA1001) only applicable to C# code? Or also to managed C++ classes?
Rule CA1001 is detected in Visual Studio when I use the provided example in C# code
public class NoDisposeMethod
{
FileStream _newFile;
public NoDisposeMethod()
{
_newFile = new FileStream(@"c:\temp.txt", FileMode.Open);
}
}
along with the following .editorconfig:
[*.{cs,cpp}]
dotnet_diagnostic.CA1001.severity = warning
However, with the example being rewritten into managed C++ this is not the case anymore:
public ref class NoDisposeMethod
{
public:
System::IO::FileStream^ _newFile;
NoDisposeMethod()
{
_newFile = gcnew System::IO::FileStream("c:\\temp.txt", System::IO::FileMode::Open);
}
};
I'm not sure if this a configuration issue or if the managed rules only apply to C# code.
Thank you very much in advance for your help!
Developer technologies | .NET | .NET Runtime
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.