SA1633 (file must have header) cannot be suppressed
See original GitHub issueWe are having a build that turns warnings into errors. StyleCop is one source of warnings in our build. The rule SA1633 is enabled because we write most code ourselves, but sometimes we use code that was published under a license. We cannot add our copyright header to those files and because the diagnostic is being reported on the first character there is no way to suppress it.
Now the only way for us is to disable this rule for all files.
A possible solution could be to check for a #pragma warning disable SA1633
in the diagnostic provider (although this is duplicate work) to work around the limitations.
Maybe we could also disable rules per file
Example of a non conforming header that cannot be changed:
#pragma warning disable SA1633 // File must have header
// *********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
// *********************************************************
#pragma warning restore SA1633 // File must have header
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
StyleCopAnalyzers/documentation/SA1633.md at master
Cause. A C# code file is missing a standard file header. Rule description. A violation of this rule occurs when a C# source...
Read more >StyleCop.Analyzers: Disable SA1633 & SA1652
I want to disable both of the following rules: SA1633: The file header is missing or not located at the top of the...
Read more >StyleCop Analyzers Implementation in .NET
In this article, we will explore StyleCop Analyzers and how to configure them to enforce the desired coding style across our team.
Read more >StyleCop: A Detailed Guide to Starting and Using It
This is the rule that requires a file header at the top of the file. ... To fix this, we simply need to...
Read more >Add file header - Visual Studio (Windows)
Learn how to use an EditorConfig file to add file headers to existing files, projects, and solutions.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@chris-eaton Any rule can be disabled using a rule set file, or by adding it to the
<NoWarn>
list in the project file.IMO: It’s better to add suppressions to
ProjectName.ruleset
file and keep all suppressions in one file than messing suppressions with project file.