Code analysis for C++/CLI
IJOLB
1
Reputation point
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
1,269 questions
Developer technologies C++
3,970 questions
Developer technologies C#
11,567 questions
Sign in to answer