I am getting many of the following warning messages. Is this something I should be concerned with?
Warning 1 The element 'PropertyGroup' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003' has invalid
child element 'ImportByWildcardBeforeMicrosoftCommonTargets' in
namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. List
of possible elements expected: 'Property, AllowUnsafeBlocks,
AppConfigForCompiler, ApplicationIcon, ApplicationRevision,
ApplicationVersion, AppDesignerFolder, AspNetConfiguration,
AssemblyKeyContainerName, AssemblyKeyProviderName, AssemblyName,
AssemblyOriginatorKeyFile, AssemblyOriginatorKeyFileType,
AssemblyOriginatorKeyMode, AssemblyType, AutorunEnabled, BaseAddress,
BootstrapperComponentsLocation, BootstrapperComponentsUrl,
BootstrapperEnabled, CharacterSet, CheckForOverflowUnderflow,
CLRSupport, CodePage, Configuration, ConfigurationName,
ConfigurationOverrideFile, CreateDesktopShortcut,
CreateWebPageOnPublish, CurrentSolutionConfigurationContents,
DebugSecurityZoneURL, DebugSymbols, DebugType, DefaultClientScript,
DefaultHTMLPageLayout, DefaultTargetSchema, DefineConstants,
DefineDebug, DefineTrace, DelaySign, DisableLangXtns,
DisallowUrlActivation, CodeAnalysisAdditionalOptions,
CodeAnalysisApplyLogFileXsl, CodeAnalysisConsoleXsl,
CodeAnalysisCulture, CodeAnalysisFailOnMissingRules,
CodeAnalysisForceOutput,
CodeAnalysisGenerateS.... C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets 20 9 Miscellaneous
Files
You can ignore this warning, see this link for an explanation:
When you apply the schema attribute to your Project element, Visual
Studio reads in the schema and uses the information indide to provide
Intellisense during your editing. As an offshoot of this, it also
warns you when it finds that you have used elements or attributes that
are not part of the schema. The custom property and item elements are
not part of the MSBuild schema.
Related
I have added the StyleCop.Analyzers NuGet package to my project (latest stable version, 1.1.118). This contains some analysis rules around ensuring that file headers are present and correct. My project also has the following stylecop.json file, with the Build Action property set to "C# analyzer additional file".
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"companyName": "Me"
}
}
}
If I add the following class to the project, it raises a warning "SA1636: The file header copyright text should match the copyright text from the settings".
// <copyright file="MyClass.cs" company="Me">
// Copyright (c) Me. All rights reserved. Some extra text to intentionally cause SA1636.
// </copyright>
namespace StackOverflowSA1636
{
/// <summary>
/// A class that I wrote.
/// </summary>
public class MyClass
{
}
}
If I remove Some extra text to intentionally cause SA1636. from the file header then the warning goes away. All good so far.
But what if I want to use a class written by someone else, either as-is or with any changes I've made? I want to credit them correctly for their code. The following class raises warning SA1636 and also "SA1641: The file header company name should match the company name from the settings".
// <copyright file="SomeoneElsesClass.cs" company="Me, Someone Else">
// Copyright (c) Me, Someone Else. All rights reserved.
// </copyright>
namespace StackOverflowSA1636
{
/// <summary>
/// A class written by someone else which I've adapted for my needs.
/// </summary>
public class SomeoneElsesClass
{
}
}
Visual Studio 2019 helpfully suggests that I can suppress these warnings in a GlobalSuppressions.cs file with attributes like this:
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage(
"StyleCop.CSharp.DocumentationRules",
"SA1636:File header copyright text should match",
Justification = "Someone else wrote the original version of this class",
Scope = "namespace",
Target = "~N:StackOverflowSA1636")]
[assembly: SuppressMessage(
"StyleCop.CSharp.DocumentationRules",
"SA1641:File header company name text should match",
Justification = "Someone else wrote the original version of this class",
Scope = "namespace",
Target = "~N:StackOverflowSA1636")]
And this does suppress the warnings, but for the whole namespace, which isn't what I want. I want to suppress them just for the one class. I tried changing them to this:
[assembly: SuppressMessage(
"StyleCop.CSharp.DocumentationRules",
"SA1636:File header copyright text should match",
Justification = "Someone else wrote the original version of this class",
Scope = "type",
Target = "~T:StackOverflowSA1636.SomeoneElsesClass")]
[assembly: SuppressMessage(
"StyleCop.CSharp.DocumentationRules",
"SA1641:File header company name text should match",
Justification = "Someone else wrote the original version of this class",
Scope = "type",
Target = "~T:StackOverflowSA1636.SomeoneElsesClass")]
While I was making this edit, Visual Studio greyed out the attribute because the Scope and Target didn't resolve to anything, but when I'd finished editing, the attributes were no longer greyed out, which makes me think that I've specified the Scope and Target correctly. However, this doesn't result in the warnings being suppressed.
Visual Studio also suggests that I can suppress SA1636 like this:
#pragma warning disable SA1636 // File header copyright text should match
// <copyright file="SomeoneElsesClass.cs" company="Me, Someone Else">
// Copyright (c) Me, Someone Else. All rights reserved.
// </copyright>
namespace StackOverflowSA1636
#pragma warning restore SA1636 // File header copyright text should match
{
/// <summary>
/// A class written by someone else which I've adapted for my needs.
/// </summary>
public class SomeoneElsesClass
{
}
}
And this does indeed suppress the warnings, but raises three new warnings:
"SA1633: The file header is missing or not located at the top of the file" (because the first line of the file is a #pragma rather than the file header)
"SA1512: Single-line comments should not be followed by blank line" (presumably because the file header is no longer be recognised as part of the file header, because it's not at the top of the file, so it's being treated as a regular comment)
"SA1515: Single-line comment should be preceded by blank line" (same reason as SA1512)
There is a solution which doesn't involve suppressing anything, to simply keep the file header the way StyleCop wants it, and then follow it with a comment crediting the original author or containing any copyright / licensing statement from the original code. This feels misleading, because the file header is effectively claiming that I'm the sole author when I'm not, but is there any better way to both satisfy StyleCop and correctly credit the original author?
Is there anything I can do to the stylecop.json file to change how the file header is validated?
Have I stumbled across a bug in StyleCop.Analyzers?
Update 9th Jan
Following some further thought, I suspect the reason I was unable to suppress the warnings using SuppressMessage is because the warnings are raised against the file rather than the class, and the Target I specified points to the class rather than the file.
Experimenting a bit with different values of the Target parameter seems to show that Visual Studio only greys out the attribute if the Target points to something that doesn't exist, but not when there's no such warning at the target to suppress. I suspect it may not be possible to target a file rather than a class, however I've had no joy finding any guidance on how to construct the Target.
This GitHub issue seems to cover my use case so I haven't created a new one: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2733
Your global suppresions based on type look correct, but I get the same result that these are not being picked up, although the suppression rule itself is highlighted/recognized.
This looks indeed candidate for a bug.
As an alternative/workaround with the expected result, you can configure that ignore rule in an .editorconfig file.
To only target that SomeoneElsesClass class, specify the targets file name in a section - here: [{SomeoneElsesClass.cs}].
You can also use a more detailed path if needed, e.g. [{Folder/SomeoneElsesClass.cs}]
[{SomeoneElsesClass.cs}]
dotnet_diagnostic.SA1636.severity = none
dotnet_diagnostic.SA1641.severity = none
I'm using StyleCop and want to suppress some warning which does not suit my style. I prefer to have solution for
1) in-line code suppressing
2) global setting suppressing
I've searched the internet but still not sure how to do the suppressing.
For method 1), They said to add the lines:
[assembly: SuppressMessage("Microsoft.Design",
"SA1202:All private methods must be placed after all public methods",
Scope = "namespace", Target = "Consus.Client.ClientVaultModule.Services.OnlineDetection")]
But they do not say where and which namespace to be used.
For method 2), they said to use GlobalSuppress file but it seems not easy to search for a how-to do it at the moment.
Please help.
[Edited]
In my case, I have the warning about SA1202: All private methods must be placed after all public methods which is bothering since I group my related codes into regions. I want to suppress those warning for just some certain methods.
Here's what you need:
[SuppressMessage("Microsoft.StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess")]
An example of inline suppression would be similar to this - examine the namespaces in the code compared to the suppression
namespace Soapi
{
///<summary>
///</summary>
///<param name = "message"></param>
///<param name = "statusCode"></param>
///<param name = "innerException"></param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object,System.Object)")]
public ApiException(string message, ErrorCode statusCode, Exception innerException)
: base(String.Format("{0}\r\nStatusCode:{1}", message, statusCode), innerException)
{
this.statusCode = statusCode;
}
A global supression file is a file in the root of your project named GlobalSuppressions.cs and might look like this:
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
//
// To add a suppression to this file, right-click the message in the
// Error List, point to "Suppress Message(s)", and click
// "In Project Suppression File".
// You do not need to add suppressions to this file manually.
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object,System.Object,System.Object)", Scope = "member", Target = "Soapi.ApiException.#.ctor(System.String,Soapi.ErrorCode,System.String,System.Exception)")]
And you can generate this code automatically by right-clicking on the warning.
Starting with StyleCop 4.3.2, it is possible to suppress the reporting of rule violations by adding suppression attributes within the source code.
Rule Suppressions
http://stylecop.soyuz5.com/Suppressions.html
but it says -
Global Suppressions
StyleCop does not support the notion of global suppressions or
file-level suppressions. Suppressions must be placed on a code
element.
If you've installed StyleCop, you can right-click your project and there will be a StyleCop option. Click this and you'll see you can prevent certain rules from even running against your project. Moreover, you can create a separate rules file to share between different projects. This means you can configure the rules once the way you want them and then share that configuration between all your projects.
For individual overrides, SuppressMessage is the way to go.
Go to Solution Explorer
Go to your project
Expand references
Expand Analyzers
Expand StyleCop.Analyzers
Right click on a particular rule which you want to disable at a global (project) level
Set Rule Set severity -> Select None
Read the admonition from Style Cop, looking for the alphanumeric code. In your case 'SA1202'. Then browse to the corresponding page on the Style Cop website. Change the URL as appropriate https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1202.md
Copy the line labelled 'How to Suppress Violations'. Paste the attribute above the class about which Style Cop moans
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "Reviewed.")]
Cant you just remove the rule instead of soiling your code?
Same goes for FxCop...
1.
In your case, correct SuppressMessage attribute should like like the following:
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess")]
private void SomeMethod()
{
}
Note that you can place it on any other element (e.g, on the class - then all similar violations in the entire class will be supressed).
I also agree that it's quite unobvious what to write in these fields.
Actually, the first one should be the fully qualified name of StyleCop analyser class and could be found from the source code (e.g. from here).
The second one should start with rule code, then colon and the name of the rule enumeration (luckily, it always looks like the rule name displayed in the Settings Editor, but with no whitespaces).
2.
Regarding suppressing rules "globally" - why don't just turn them off via Settings Editor? Settings files are inherited through the file system, so you could easily have one "main" settings file at the "top" of your folder structure, and some other files (holding the "difference" from main) with exceptions made for some projects, if you want so (like described here).
Good luck!
You can disable the rules you don't want in Settings.StyleCop file, which is in the project root folder.
You will need the namespace that contains the rule, which can be found here:
http://stylecop.soyuz5.com/StyleCop%20Rules.html
Settings.stylecop file code for your reference:
<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.LayoutRules">
<Rules>
<Rule Name="ElementsMustBeSeparatedByBlankLine">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
Alternatively you could move the code in regions into partial classes. Then the issue with the stylecop rule will go away.
In addition to the helpful answers already in place:
If you suppress a warning in the suppression file GlobalSuppressions.cs,
you can edit that [assembly: SuppressMessage(StyleCop...blabla line and entirely remove the Scope=... and Target=... tags. That makes the suppression global in the project.
The README.md for the StyleCop.Analyzers NuGet package used by Visual Studio 2015+ contains a link to the documentation for the rules. The documentation for each rule contains a "How to suppress violations" section. For the SA1202 rule, the options are:
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "Reviewed.")]
and
#pragma warning disable SA1202 // ElementsMustBeOrderedByAccess
#pragma warning restore SA1202 // ElementsMustBeOrderedByAccess
I'm getting designer error on code:
The Component i'm willing to define a List of properties for:
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
namespace TestProjectForProperty.Test
{
public class MyTreeView : TreeView
{
private List<TypeDescriptorBase> _descriptorsAvailable = new List<TypeDescriptorBase>();
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public List<TypeDescriptorBase> DescriptorsAvailable
{
get { return _descriptorsAvailable; }
set { _descriptorsAvailable = value; }
}
}
}
The Descriptor itself:
using System;
namespace TestProjectForProperty.Test
{
[Serializable]
public class TypeDescriptorBase
{
public string Name { get; set; }
public override string ToString()
{
return Name;
}
}
}
I am getting the following error if i try to use the component for example on a form and add any items on the property sheet or in the component's constructor to the DescriptorsAvailable property
Error 1 Invalid Resx file. Could not load type
System.Collections.Generic.List`1[[TestProjectForProperty.Test.TypeDescriptorBase,
TestProjectForProperty, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 which is used in the .RESX file.
Ensure that the necessary references have been added to your project.
Line 134, position 5. ...\visual studio
2010\Projects\TestProjectForProperty\TestProjectForProperty\Form1.resx 134 5 TestProjectForProperty
In the Resx file there is data field with base64 encoded stuff inside when this error is present.
I have been searching for an answer, but the best i got is to restart everything, it didn't help me, do you guys have any suggestions? I'm using .net 4 client and visual studio 2010
In my experience, this is due to a change of version of a referenced library, or a change of the lib itself, which contains the backing type of a property you have defined in your user control. The solution is to "force" the visual studio designer to re-initialize it's designer code for that type, and not expect to retrieve a "canned" version of it from the .resx file of the control.
1) Delete the offending data section in the .resx file of your control. This will be a section in the xml of the .resx file associated with your user control, which has a node: <data></data> - the name attribute will be set to whatever you've named that object in the properties of whatever you added this type to. The <data>/data> section contains a base64 encoded string that is the encoded form of the name and version of the library the type comes from. This is where the problem ism, because it now contains an encoded version of the library and/or version number you are no longer referencing in order to include the type. Delete the entire <data>/data> section, from opening to closing tag, save the change and close the file. Now the "artifact" is gone.
2) Now find the place in the designer file for your control, where the type is instantiated; this is initialization code generated for you by visual studio, and it is the place that is expecting to load a "canned" definition of the type from the base64 encoded string contained within the .resx file. The line will look something like this:
this.myCtrlFoo.MyPropertyFroo = ((MyNamespaceFoo.MyTypeFoo)(resources.GetObject("myCtrlFoo.MyPropertyFroo")));
...now just replace the resources.GetObjec call with the instantiation of a new instance of the appropriate type like so:
this.myCtrlFoo.MyPropertyFroo = ((MyNamespaceFoo.MyTypeFoo)(new MyNamespaceFoo.MyTypeFoo()));
...now save the change to the file, close it, rebuild, and everything should now build & run OK.
Put the MyTreeView and TypeDescriptorBase classes into another project and reference it from your GUI project will resolve the issues.
I'm not sure why exactly the problem occurs - I guess it has something to do with the way the serializing process is generating the base64 string for the DescriptorsAvailable Property. Maybe somebody else can give us some insight.
I've struggled quite a bit with this; I have three user controls that all expose the same non-designer property, but for some reason, any change to two of the three would instantly cause the next build to fail with this same issue. This is in VS 2015.
I wound up having to add the following two attributes to the property that kept expanding in the resx file, and it hasn't occurred since. It works for me because they're not available in the designer anyway.
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
For me, this error occured when I used a custom class as a property for the user control. When I switched from property to traditional get- and set- methods, the error disappeared. I guess this is because properties are already compiled at design-time, so when you build the whole project, a new version of the custom class is compiled which is separate from the one of the control, and the reference is broken.
For me, with the custom class Inventory, all I had to do was to switch from this property-based approach:
public Inventory Resources {get;set;}
to this method-based approach:
private Inventory resources;
public Inventory getResources() { return resources; }
public void setResources(Inventory newResources) { resources = newResources; }
I hope this helps someone, as I've been spending some hours on figuring it out.
In my case I've got the error : "error MSB3103: Invalid Resx file. The specified module could not be found" executed in a light windows container based on mcr.microsoft.com/powershell instead of mcr.microsoft.com/windows:1909 (was working fine on 1909).
The error was on a ressource icon that was compressed with PNG inside.
It can be checked by opening the ressource on visual studio : Project > Properties > Ressources.resx, select icons, double click on the icon, check the end of the title that is either "..,BMP]" or "...,PNG]").
Updating the icon with an uncompressed format solve the "Invalid Resx file" issue.
I stumbled across this question today whilst looking for the solution to a similar issue.
Unfortunately none of the above worked for me, however my issue turned out to be that I had different versions of the .NET Framework for different projects. For example;
Project A - .NET Framework 4.7.2
Project B - .NET Framework 4
Where Project B was referencing Project A. Solution was simply to change the .NET Framework version of Project B to 4.7.2 (in my case) and hey presto the issue was resolved.
A shame Visual Studio doesn't provide a more helpful error message in this case, but something to look out for!
I have a class like this one:
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Io")]
public void ParaQueFalleCalidadCodigoUnoIo_ReglaCA1709()
{
}
public void ParaQueFalleCalidadCodigoDosIo_ReglaCA1709()
{
}
I use a custom Ruleset file CustomRules.ruleset
<RuleSet Name="RulesNet" ToolsVersion="10.0">
<RuleHintPaths>
<Path>C:\Fxcop10.0\Rules</Path>
</RuleHintPaths>
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1709" Action="Warning" />
</Rules>
</RuleSet>
When I run VS2010 built in Code Analysis tool, I get this warning:
CA1709 : Microsoft.Naming : Correct the casing of 'Io' in member name
'_Default.ParaQueFalleCalidadCodigoDosIo_ReglaCA1709()' by changing it
to 'IO'.
Now, I can use this same rule set file CustomRules.ruleset in FxCopCmd.exe:
FxCopCmd.exe /gac /d:"C:\CompanyFramework\4.0.0.0" /f:"D:\TFS\Tests\WebApplication1\bin\WebApplication1.dll" /o:"resultsFxCop.xml" /ruleset:"=CustomRules.ruleset" /v
I get 2 errors (FixCategory Breaking, and Level Error)
CA1709 - Correct the casing of 'Io' in member name
'_Default.ParaQueFalleCalidadCodigoUnoIo_ReglaCA1709()' by changing it
to 'IO'.
CA1709 - Correct the casing of 'Io' in member name
'_Default.ParaQueFalleCalidadCodigoDosIo_ReglaCA1709()' by changing it
to 'IO'.
<Message Id="Io" TypeName="IdentifiersShouldBeCasedCorrectly" Category="Microsoft.Naming" CheckId="CA1709" Status="Active" Created="2013-02-05 10:24:01Z" FixCategory="Breaking">
<Issue Name="Member" Certainty="85" Level="Error" Path="D:\TFS\Tests\WebApplication1" File="Default.aspx.cs" Line="21">Correct the casing of 'Io' in member name '_Default.ParaQueFalleCalidadCodigoUnoIo_ReglaCA1709()' by changing it to 'IO'.</Issue>
</Message>
<Message Id="Io" TypeName="IdentifiersShouldBeCasedCorrectly" Category="Microsoft.Naming" CheckId="CA1709" Status="Active" Created="2013-02-05 10:24:01Z" FixCategory="Breaking">
<Issue Name="Member" Certainty="85" Level="Error" Path="D:\TFS\Tests\WebApplication1" File="Default.aspx.cs" Line="26">Correct the casing of 'Io' in member name '_Default.ParaQueFalleCalidadCodigoDosIo_ReglaCA1709()' by changing it to 'IO'.</Issue>
</Message>
In resultsFxcop.xml, I have seen CA1709: IdentifiersShouldBeCasedCorrectly rule:
<Rule TypeName="IdentifiersShouldBeCasedCorrectly" Category="Microsoft.Naming" CheckId="CA1709">
<Name>Identifiers should be cased correctly</Name>
<Description>Type, namespace, and... OMITED.</Description>
<Resolution Name="Member">Correct the casing of '{0}' in member name {1} by changing it to '{2}'.</Resolution>
<Owner />
<Url>http://msdn.microsoft.com/library/ms182240(VS.100).aspx</Url>
<Email>[none]</Email>
<MessageLevel Certainty="85">Error</MessageLevel>
<File Name="namingrules.dll" Version="10.0.0.0" />
</Rule>
MessageLevel for CA1709 rule:
<MessageLevel Certainty="85">Error</MessageLevel>
Two issues:
I get Errors but CA1709 rule Action is Warning
SuppressMessage is ignored using FxCopcmd.exe
Now, I modify CustomRules.ruleset and I execute FxCopcmd.exe again
<Rule Id="CA1709" Action="None" />
I get NO errors.
I modify CustomRules.ruleset and I execute FxCopcmd.exe again
<Rule Id="CA1709" Action="Ignore" />
I get the same 2 errors.
I need use FxCopCmd.exe and a custom ruleset.
Does SuppressMessage works for FxCopcmd.exe?
Why do I get errors if Action is Warning, using Fxcopcmd.exe?
What does MessageLevel Error for CA1709 rule mean? More priority than Rule Action "Warning"?
Any suggestions?
Update
http://social.msdn.microsoft.com/Forums/en/vstscode/thread/3f8931da-9a4d-47a6-b331-8b6b07aea8d6
http://social.msdn.microsoft.com/forums/en-US/vstscode/thread/3cb6c50c-7095-4551-a4e3-a3cbc7cb85be
For the default FxCop rules, there is no easy way to modify the message level,
MessageLevel is the importance of the message, e.g. if you had thousands of messages, it probably would be a good idea to start addressing the Critical (the exclamation mark) Errors first.
Certainty is the number the Rule writer assigns to each rule, it is the likelihood that a message leads to a code change. This number is built up based on feedback from domain experts & customers and how well the heuristic used in the rule is able to avoid false positives.
Fix Category: This indicates if the fix for a violation would be a binary breaking change if the code has previously shipped. e.g you have a library with a misspelling in it that you have already shipped to customers. You now start running FxCop on it and see the misspelling. FxCop will tell you this is a breaking change. If you fix the misspelling and ship a new version of your library to customers, they can't use the library without changing and recompiling their code. So you probably want to ignore the FxCop violation on this API. On the other hand, if you never shipped, it would be totally fine to fix the FxCop violation.
Does SuppressMessage works for FxCopcmd.exe?
Yes. You will need to compile with the CODE_ANALYSIS compilation symbol defined in order for your SuppressMessage attributes to be included in your assembly. Once they're in there, the FxCop engine will recognize them, regardless of the mechanism used to run the analysis.
Why I get errors if Action is Warning, using Fxcopcmd.exe?
The issue level written to the FxCop-produced report always uses the level specified by the rule author. When you run from within Visual Studio, the Visual Studio integration plug-in overrides this level with the one specified in the ruleset. When you run fxcopcmd.exe, the only difference between a configuring a rule as a warning vs an error is that detection of an error-level rule violation will cause fxcopcmd.exe to return a non-zero exit code, thereby allowing you to break an automated build.
If you would prefer that fxcopcmd.exe use your level overrides when generating its report, you may want to consider making a suggestion at http://visualstudio.uservoice.com/.
I have a very large C# project, with over 100 warnings, all triggered by the file:
Microsoft.CppBuild.targets
Is there a way to suppress these types of warnings:
The element 'ResourceCompile' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element
'MinimalRebuildFromTracking' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003'. List of possible elements
expected: 'Culture, PreprocessorDefinitions, UndefinePreprocessorDefinitions,
AdditionalIncludeDirectories, IgnoreStandardIncludePath, ShowProgress,
NullTerminateStrings, SuppressStartupBanner, ResourceOutputFileName' in namespace
'http://schemas.microsoft.com/developer/msbuild/2003'. C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 172 10
Miscellaneous Files
Other warnings start with:
The Element 'Midl' ...
The Element 'PropertyGroup' ...
The Element 'Manifest' ...
The Element 'Link' ...
The Element 'ItemGroup' ...
The Element 'ClCompile' ...
Environment
Visual Studio 2010 SP1
ReSharper
Solution was to close the file "Microsoft.CppBuild.targets".