Home > .NET > SA0001: An exception occurred while parsing the file – Caused by an optional string argument

SA0001: An exception occurred while parsing the file – Caused by an optional string argument

I was presented with this StyleCop error by a member of my team the other day.

SA0001: An exception occurred while parsing the file: System.ArgumentNullException, element
Parameter name: Must not be null
   at Microsoft.StyleCop.Param.RequireNotNull(Object parameter, String parameterName, ParamErrorTextHandler errorTextHandler)
   at Microsoft.StyleCop.Param.RequireNotNull(Object parameter, String parameterName)
   at Microsoft.StyleCop.StyleCopAddIn.AddViolation(ICodeElement element, Int32 line, String ruleName, Object[] values)
   at Microsoft.StyleCop.StyleCopAddIn.AddViolation(ICodeElement element, Int32 line, Enum ruleName, Object[] values)
   at Microsoft.StyleCop.CSharp.ReadabilityRules.CheckEmptyString(Node`1 stringNode)
   at Microsoft.StyleCop.CSharp.ReadabilityRules.IterateTokenList(CsDocument document, Settings settings)
   at Microsoft.StyleCop.CSharp.ReadabilityRules.AnalyzeDocument(CodeDocument document)
   at Microsoft.StyleCop.StyleCopThread.RunAnalyzers(CodeDocument document, SourceParser parser, IEnumerable`1 analyzers)
   at Microsoft.StyleCop.StyleCopThread.TestAndRunAnalyzers(CodeDocument document, SourceParser parser, IEnumerable`1 analyzers, Int32 passNumber)
   at Microsoft.StyleCop.StyleCopThread.ParseAndAnalyzeDocument(SourceCode sourceCode, DocumentAnalysisStatus documentStatus)
   at Microsoft.StyleCop.StyleCopThread.DoWork(Object sender, DoWorkEventArgs e).

It took some time to track down, but the below link helped point me in the right direction.

http://stylecop.codeplex.com/workitem/6755

The problem was an optional string argument in a method.

There is a bug in StyleCop which has now apparently been fixed in version 4.4.1

Looks like we have an upgrade to do…

Advertisements
Categories: .NET
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: