Search code examples
c#visual-studio-2012code-analysis

How to resolve Code Analysis - CA1720 for GUID datatype


CA1720 for datatype GUID, Warning shown as follows:

CA1720 Identifiers should not contain type names In member 'ABCService.GetReport(Guid)', consider replacing the data type identifier 'GUID' in parameter name 'reportGUID' with a more generic term, such as 'value'.

How to handle GUID datatype?


Solution

  • From MSDN

    If fired against a parameter: Replace the data type identifier in the name of the parameter with either a term that better describes its meaning or a more generic term, such as 'value'.

    If fired against a member: Replace the language-specific data type identifier in the name of the member with a term that better describes its meaning, a language-independent equivalent, or a more generic term, such as 'value'.

    Simply use a classic Id, Uid, UniqueIdentifier, ... and not Guid.

    Suppress the rule if you think it's important or if the library have been previous shipped

    [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames")]