如何抑制托管cpp中方法的代码分析错误 [英] How to supress code analysis error for a method in managed cpp

查看:93
本文介绍了如何抑制托管cpp中方法的代码分析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法签名:

虚拟 void GetStateData( Guid commandId 向导 dataSourceId IEnumerable 向导 stateIds IEnumerable DateTime startTimes DateTime endTime );

virtual void GetStateData(Guid commandId, Guid dataSourceId, IEnumerable<Guid>^ stateIds, IEnumerable<DateTime>^ startTimes, DateTime endTime);

班级名称:

DataServiceManagedCPPWrapper

在此托管cpp项目上运行代码分析时,出现CA2123错误.

I am getting CA2123 error while running code analysis on this managed cpp project.

请使用语法帮助我,以抑制GlobalSuppression.cpp文件中的出现.

Please help me with syntax to suppress this in GlobalSuppression.cpp file.


推荐答案

嗨阿南德·莫卡西(

Hi Anand Mokas

您使用哪个C ++项目? DataServiceManagedCPPWrapper是否实现某些接口?

Which C++ project do you use? Does the DataServiceManagedCPPWrapper implement some interface?

我创建一个CLR->类库项目,并使用GetStateData方法添加一个DataServiceManagedCPPWrapper类.在此托管项目上运行代码分析时,我没有收到有关CA2123的任何错误和警告.

I create a CLR -> Class Library project and add a DataServiceManagedCPPWrapper class with GetStateData method. When running code analysis on this managed project, I don't get any error and warning about CA2123.

根据CA2123代码,此问题通常是由以下原因引起的:公共类型中的公共或受保护方法将覆盖方法或实现接口,并且不具有相同的含义. 链接需求 作为界面或虚拟方法".请参阅以下文档以解决此错误,然后尝试使用固定的方法检查它是否可以解决您的问题.

According to the CA2123 code, this issue often caused by "A public or protected method in a public type overrides a method or implements an interface, and does not have the same Link Demands as the interface or virtual method". Please refer to following document for this error and try the fixed way to check whether it could fix your issue.

https://msdn.microsoft.com/en-us/library/ms182305.aspx

最好的问候,
Weiwei

Best Regards,
Weiwei


这篇关于如何抑制托管cpp中方法的代码分析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆