question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SA1633 (file must have header) cannot be suppressed

See original GitHub issue

We 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:open
  • Created 8 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sharwellcommented, Jan 10, 2019

@chris-eaton Any rule can be disabled using a rule set file, or by adding it to the <NoWarn> list in the project file.

0reactions
umbarovcommented, May 7, 2020

IMO: It’s better to add suppressions to ProjectName.ruleset file and keep all suppressions in one file than messing suppressions with project file.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found