Skip to content

NET-3640 Fix S3400 FP: Don't report function with conditional compilation body #9804

Open

Description

@tkouba

Description

On multi-platform or multi-target code, sometimes need to return constant on some platforms/targets.

Reproducer

        public static bool IsGooglePlayServicesAvailable()
        {
#if ANDROID
            try
            {
                var context = Android.App.Application.Context;
                var result = Android.Gms.Common.GoogleApiAvailability.Instance
                    .IsGooglePlayServicesAvailable(context);

                return result == Android.Gms.Common.ConnectionResult.Success;
            }
            catch
            {
                return false;
            }
#else
            // iOS / Windows platform fallback 
            return false;
#endif
        }

Product and Version

VisualStudio: 17.14.29, SonarQube ide 9.9.0.16495

Activity

  1. pavel-mikula-sonarsource commented on Apr 22, 2026

    @pavel-mikula-sonarsource
    Contributor

    Aho Tomáši,

    Thank you for reporting this case, I confirm it as a False Positive.

  2. github-actions commented on Apr 22, 2026

    @github-actions
    Contributor

    Internal ticket NET-3640

  3. changed the title [-]Fix S3400 FP: Don't report function with conditional compilation body[/-] [+]NET-3640 Fix S3400 FP: Don't report function with conditional compilation body[/+] on Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    False PositiveRule IS triggered when it shouldn't be.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions