6

I'm pretty sure that previous versions of Visual Studio Code Analysis warned about the use of NotImplementedException, i.e. any member that contained this

throw new NotImplementedException();

would give a CA warning.

This doesn't seem to be the case with Visual Studio 2008.

Was that particular rule removed, or am I just imagining that it ever existed?

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
  • No warning from VS 2005, and also no relevant google results for `"how to fix violations" NotImplementedException` - I don't think this was or was part of the default ruleset. – AakashM Feb 25 '10 at 10:14
  • Perhaps it was in FxCop, but never in VS... – Mark Seemann Feb 25 '10 at 12:37

4 Answers4

4

You are probably thinking about this FxCop warning that you get when throwing NotImplementedException from special methods such as a property getter, event accessor, Equals, GetHashCode, Dispose etcetera:

CA1065 : Microsoft.Design : 'SomeClass.SomeProperty.get()' creates an exception of type 'NotImplementedException', an exception type that should not be raised in a property. If this exception instance might be raised, use a different exception type, convert this property into a method, or change this property's logic so that it no longer raises an exception.

However, it is not explicitly related to NotImplementedException. FxCop has white lists for the exceptions that may be (directly) thrown by these methods.

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
1

I don't recall ever seeing such a rule in the Microsoft-shipped rule set. It's one of the first custom rules I've created at the day job since at least the days of FxCop 1.35, so I'd have to guess that it harkens back to the days of FxCop 1.32 if it did ever exist...

Nicole Calinoiu
  • 20,843
  • 2
  • 44
  • 49
  • I'm beginning to think that my memory is playing tricks with me, but if not, it sure has been a long time since I remember seeing it. – Mark Seemann Mar 01 '10 at 19:35
1

I know this is an old question, but I'm getting this as a warning (12 Sep 2017), when running Code Analysis, using Visual Studio 2017. It is the "CA1065" code that Wim Coenen mentions, so it seems Microsoft must have ported FxCop rules to the Roslyn-based analysis platform.

Link provided in Error List window

ryanwebjackson
  • 1,017
  • 6
  • 22
  • 36
0

Unfortunately, there isn't such a rule in the standard ruleset.

You can find my implementation of it in one of my other answers.

Community
  • 1
  • 1
R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510