Questions tagged [ca1062]
9 questions
11
votes
2 answers
Why do I get Code Analysis CA1062 on an out parameter in this code?
I have a very simple code (simplified from the original code - so I know it's not a very clever code) that when I compile in Visual Studio 2010 with Code Analysis gives me warning CA1062: Validate arguments of public methods.
public class Foo
{
…

brickner
- 6,595
- 3
- 41
- 54
10
votes
5 answers
CA1062: ValidateArgumentsOfPublicMethods on co-constructor calls
I have a class with two constructors that look like this:
public MyClass(SomeOtherClass source) : this(source, source.Name) { }
public MyClass(SomeOtherClass source, string name) { /* ... */ }
When I run FxCop, it correctly reports a violation of…

SLaks
- 868,454
- 176
- 1,908
- 1,964
7
votes
3 answers
Should I suppress CA1062: Validate arguments of public methods?
I've recently upgraded my project to Visual Studio 2010 from Visual Studio 2008.
In Visual Studio 2008, this Code Analysis rule doesn't exist.
Now I'm not sure if I should use this rule or not.
I'm building an open source library so it seems…

brickner
- 6,595
- 3
- 41
- 54
4
votes
1 answer
CA1062 not evaluating on .Net Standard 2.0 class library
I'm unable to get CA1062 (validate arguments of public methods) to evaluate.
I've created a .Net Standard 2.0 C# class library and installed Microsoft.CodeQuality.Analyzers and several others nuget packages as per this screenshot:
I've also enabled…

Cornelius
- 3,526
- 7
- 37
- 49
2
votes
1 answer
CA1062 (Code Analysis) disagrees with ReSharper -- Who wins?
protected override void OnTextInput(TextCompositionEventArgs e)
{
e.Handled = true;
DoSomething(e.Text);
}
If I check for null, CA is happy, but ReSharper says that the null check will always be false. I'm not sure who is more trust-worthy…

myermian
- 31,823
- 24
- 123
- 215
1
vote
1 answer
Can't suppress FxCop Warning CA1062
c#/.net/fxcop!
... within a class, I want FxCop to shut up complaining about
Warning CA1062 : Microsoft.Design :
In externally visible method 'xyz', validate parameter 'a' before using it.
Basically, this rule suggests that I put a if (a ==…

Efrain
- 3,248
- 4
- 34
- 61
1
vote
0 answers
Code analysis warning: CA1062 is really false positive?
In my code, I have a reference variable LogValidacionPagosDTO
public void InsertarArchivoXmlOk(ArchivoXmlDRO archivo, ref LogValidacionPagosDTO archivoRespuesta)
{
//Some code
}
When executing "code analysis" generates this warning
Warning…

makitocode
- 938
- 1
- 16
- 40
0
votes
1 answer
Why compiller stills trhowing CA1062 once I validated public nullable parameter?
I just enabled FxCop Code Analyzers and, while fixing warnings this one could not be fixed:
CA1062: Validate arguments of public methods
public static string SanitizeFileName(this string fileName)
{
if (fileName is null)…

Arthur JF
- 81
- 5
-2
votes
1 answer
Fix FxCop CA1062 by generating validation for parameter
Turning the Code anlyisis on for a big project is showing a huge amount of CA1062 wanings, which are absolutely right IMO.
I would like to handle these automatically without having to go through each one,is there anyway to automate this in the…

CloudyMarble
- 36,908
- 70
- 97
- 130