Skip to content

Warning CA1416 : This call site is reachable on: 'Android' 21.0 and later. 'Paint.Color.set' is only supported on: 'android' 29.0 and later. #6606

@lauxjpn

Description

@lauxjpn

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

.NET 6.0.100

Description

I have the following properties setup in my project:

<TargetFramework>net6.0-android</TargetFramework>
<SupportedOSPlatformVersion>21.0</SupportedOSPlatformVersion>

I have the following code:

public sealed class FooDrawable : ShapeDrawable
{
    public FooDrawable()
        : base(new RectShape())
    {
        Paint.Color = Color.Black; // [CA1416]
    }
}

The following warning is being output, which is unexpected:

Warning CA1416 : This call site is reachable on: 'Android' 21.0 and later. 'Paint.Color.set' is only supported on: 'android' 29.0 and later.

According to the android reference, there are two setColor() overloads:

setColor(int) [Added in API level 1]
setColor(long) [Added in API level 29]

It seems that the warning is referring to the latter one, even though using the first one is sufficient here.

Steps to Reproduce

Set the Color property of the Paint class, rebuild the project and observe the warning.

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

Labels

Area: Mono.AndroidIssues with the Android API binding (Mono.Android.dll).needs-triageIssues that need to be assigned.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions