Use of GlobalSuppressions.cs i StyleCop Runner in Azure Pipeline












0















I have a c# solution that adhere to our custom StyleCop rules as specified in stylecop.json and GlobalSuppresions.cs. Both are located in the solution root and linked each project via their .csproj files.



I have an Azure DevOps pipeline set up to build the entire solution and also run StyleCop on it using the runner. However, although our stylecop.json settings are respected by the runner, the GlobalSuppresions.cs ones aren't. In the runner there is an option to specify a path for a settings file, but none for GlobalSuppresions.cs.



The question is: Is there a way to make the runner understand GlobalSuppressions.cs? Or is there a way to merge our rules into stylecop.json?










share|improve this question



























    0















    I have a c# solution that adhere to our custom StyleCop rules as specified in stylecop.json and GlobalSuppresions.cs. Both are located in the solution root and linked each project via their .csproj files.



    I have an Azure DevOps pipeline set up to build the entire solution and also run StyleCop on it using the runner. However, although our stylecop.json settings are respected by the runner, the GlobalSuppresions.cs ones aren't. In the runner there is an option to specify a path for a settings file, but none for GlobalSuppresions.cs.



    The question is: Is there a way to make the runner understand GlobalSuppressions.cs? Or is there a way to merge our rules into stylecop.json?










    share|improve this question

























      0












      0








      0








      I have a c# solution that adhere to our custom StyleCop rules as specified in stylecop.json and GlobalSuppresions.cs. Both are located in the solution root and linked each project via their .csproj files.



      I have an Azure DevOps pipeline set up to build the entire solution and also run StyleCop on it using the runner. However, although our stylecop.json settings are respected by the runner, the GlobalSuppresions.cs ones aren't. In the runner there is an option to specify a path for a settings file, but none for GlobalSuppresions.cs.



      The question is: Is there a way to make the runner understand GlobalSuppressions.cs? Or is there a way to merge our rules into stylecop.json?










      share|improve this question














      I have a c# solution that adhere to our custom StyleCop rules as specified in stylecop.json and GlobalSuppresions.cs. Both are located in the solution root and linked each project via their .csproj files.



      I have an Azure DevOps pipeline set up to build the entire solution and also run StyleCop on it using the runner. However, although our stylecop.json settings are respected by the runner, the GlobalSuppresions.cs ones aren't. In the runner there is an option to specify a path for a settings file, but none for GlobalSuppresions.cs.



      The question is: Is there a way to make the runner understand GlobalSuppressions.cs? Or is there a way to merge our rules into stylecop.json?







      c# azure azure-devops azure-pipelines stylecop






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 '18 at 11:06









      piuspius

      1,0261319




      1,0261319
























          1 Answer
          1






          active

          oldest

          votes


















          0














          So... since I wrote the questions I've learned a couple of things.



          In newer versions of Visual Studio the "Roslyn Analyzers" are supposed to be used. While the stylecop analyzers nuget package adhere to GlobalSuppressions.cs, and automatically create such files when requested via code fixes, that is not the recommended approach. Instead rulesets should be used. Rulesets are different from stylecop settings files which come in a new and old version. The new version is the .json one.



          Rulesets are understood by the compiler directly, so there is no longer a need for the Azure DevOps build task that we were using. I simply created a ruleset that matched what we had in GlobalSuppressions.cs and started using that for development. For our release configuration, which is what we use on Azure DevOps I created a copy of the ruleset, but with all the rules we use set to Error rather than Warning.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429592%2fuse-of-globalsuppressions-cs-i-stylecop-runner-in-azure-pipeline%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            So... since I wrote the questions I've learned a couple of things.



            In newer versions of Visual Studio the "Roslyn Analyzers" are supposed to be used. While the stylecop analyzers nuget package adhere to GlobalSuppressions.cs, and automatically create such files when requested via code fixes, that is not the recommended approach. Instead rulesets should be used. Rulesets are different from stylecop settings files which come in a new and old version. The new version is the .json one.



            Rulesets are understood by the compiler directly, so there is no longer a need for the Azure DevOps build task that we were using. I simply created a ruleset that matched what we had in GlobalSuppressions.cs and started using that for development. For our release configuration, which is what we use on Azure DevOps I created a copy of the ruleset, but with all the rules we use set to Error rather than Warning.






            share|improve this answer




























              0














              So... since I wrote the questions I've learned a couple of things.



              In newer versions of Visual Studio the "Roslyn Analyzers" are supposed to be used. While the stylecop analyzers nuget package adhere to GlobalSuppressions.cs, and automatically create such files when requested via code fixes, that is not the recommended approach. Instead rulesets should be used. Rulesets are different from stylecop settings files which come in a new and old version. The new version is the .json one.



              Rulesets are understood by the compiler directly, so there is no longer a need for the Azure DevOps build task that we were using. I simply created a ruleset that matched what we had in GlobalSuppressions.cs and started using that for development. For our release configuration, which is what we use on Azure DevOps I created a copy of the ruleset, but with all the rules we use set to Error rather than Warning.






              share|improve this answer


























                0












                0








                0







                So... since I wrote the questions I've learned a couple of things.



                In newer versions of Visual Studio the "Roslyn Analyzers" are supposed to be used. While the stylecop analyzers nuget package adhere to GlobalSuppressions.cs, and automatically create such files when requested via code fixes, that is not the recommended approach. Instead rulesets should be used. Rulesets are different from stylecop settings files which come in a new and old version. The new version is the .json one.



                Rulesets are understood by the compiler directly, so there is no longer a need for the Azure DevOps build task that we were using. I simply created a ruleset that matched what we had in GlobalSuppressions.cs and started using that for development. For our release configuration, which is what we use on Azure DevOps I created a copy of the ruleset, but with all the rules we use set to Error rather than Warning.






                share|improve this answer













                So... since I wrote the questions I've learned a couple of things.



                In newer versions of Visual Studio the "Roslyn Analyzers" are supposed to be used. While the stylecop analyzers nuget package adhere to GlobalSuppressions.cs, and automatically create such files when requested via code fixes, that is not the recommended approach. Instead rulesets should be used. Rulesets are different from stylecop settings files which come in a new and old version. The new version is the .json one.



                Rulesets are understood by the compiler directly, so there is no longer a need for the Azure DevOps build task that we were using. I simply created a ruleset that matched what we had in GlobalSuppressions.cs and started using that for development. For our release configuration, which is what we use on Azure DevOps I created a copy of the ruleset, but with all the rules we use set to Error rather than Warning.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 29 '18 at 17:15









                piuspius

                1,0261319




                1,0261319
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429592%2fuse-of-globalsuppressions-cs-i-stylecop-runner-in-azure-pipeline%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    RAC Tourist Trophy