Skip to content

#IfNot Inspection #5945

@retailcoder

Description

@retailcoder

What
Flag precompiler directives involving a Not operator flipping a precompiler constant.

Why
Truthy value is 1, which yields unexpected results when a Not operator gets involved.

Example
This code should trigger the inspection:

#If Not Win64 Then ' expression is always true
#EndIf

QuickFixes

  1. Use Explicit Equality Check

    Example code, after quickfix is applied:

    #If Win64 = 0 Then
    #EndIf

Resources
Each inspection needs a number of resource strings - please provide a suggestion here:

  • PrecompilerConditionAlwaysTrue: the name of the inspection, as it appears in the inspection settings.
  • InspectionInfo: precompiler constants have a truthy value of 1, which makes 'Not' operators yield an unexpected non-zero, truthy value: the expression is always true.
  • InspectionResults: Precompiler expression '{0}' is always true

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests, or enhancements to existing features. Ideas. Anything within the project's scope.feature-inspectionsup-for-grabsUse this label in conjunction with a difficulty level label, e.g. difficulty-02-ducky

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions