locked
Suppress CA Warning doesn't work in Visual Studio 2017 (C++/CLI project) RRS feed

  • Question

  • When I try to Suppress Warning > In Suppression File in my vcxproj (C++/CLI), I get an error message "A file with the name d:\path\to\ClassLibrary1\ already exists on disk." and then "Cannot suppress the warning".

    Is it a known limitation of Visual Studio 2017? Or am I missing some configuration?

    Steps to reproduce:

    - create vcxproj in Visual Studio 2017 15.4.1 with Code Analysis enabled;

    - modify the base "Microsoft Mixed (C++ /CLR) Recommended Rules to include CA1812;

    - add the following classes;

    - build Release configuration and try to suppress CA1812

    template<class T> private ref class Editable {
    public: virtual void BeginEdit() {  }
    protected: Editable() {};
    };
    
    namespace ClassLibrary1 {
    
      public interface class IPanelUser
      {
        property int UserID { int get(); void set(int); }
      };
    
      private ref class PanelUser : public  IPanelUser, Editable<int>
      {
      public:
        PanelUser()
        {
        };
    
        virtual property int UserID
        {
          int get() { return 0; }
          void set(int value) { }
        }
      };
    
      public ref class Project
      {
      public:
        IPanelUser^ GetUser() { return gcnew PanelUser(); }
      };
    }
    

    Sunday, October 22, 2017 12:04 PM

Answers

All replies

  • >When I try to Suppress Warning > In Suppression File in my vcxproj (C++/CLI), I get an error message "A file with the name d:\path\to\ClassLibrary1\ already exists on disk." and then "Cannot suppress the warning".

    I can reproduce this with the current preview version.

    Please submit a bug report on this using the VS "Report a Problem" facility.

    If you can post a link back here to your bug report, I'll vote/validate it.

    Thanks
    Dave

    Sunday, October 22, 2017 6:04 PM
  • I think I followed instructions and when I try to check the checkbox for CA1812 I get "Object reference not set to an instance of an object".

    If you suspect a bug then you should check in Visual Studio Questions - Developer Community. I don't find something describing the problem I have but the following are similar.

    Code Analysis rulesets ignored - Developer Community

    Cannot create rule set - Developer Community



    Sam Hobbs
    SimpleSamples.Info

    Sunday, October 22, 2017 6:51 PM
  • Dave,

    Thank you for the confirmation!

    Hopefully, you can find the report at https://developercommunity.visualstudio.com/content/problem/135815/suppress-ca-warning-doesnt-work-in-visual-studio-2.html

    Sam,

    it did take me couple attempts to edit the ruleset, but it's a different problem and the original question doesn't depend on the particular rule. It's just I could easily extract short code that shows the problem with CA1812.

    Thank you, both!

    --
    Kirill

    • Proposed as answer by Weiwei Cai Monday, October 23, 2017 3:06 AM
    • Marked as answer by Kirill at Work Monday, October 23, 2017 10:34 AM
    Sunday, October 22, 2017 7:53 PM
  • Hi Kirill,

    Thanks for your feedback for Visual Studio 2017 product.

    Since you have submit this issue to Developer Community, please wait for the response from Visual Studio Product Team patiently. And if possible, please mark your feedback reply as answer, which could let other communities who has the same problem to vote and add comments. And if there has any result from Visual Studio Product team, communities could view the result through your feedback link.

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 23, 2017 3:05 AM