Skip to content

CLS Compliance warning CS3016 is reported on non-public members #4293

@dsplaisted

Description

@dsplaisted

Compile the following code:

using System;

[assembly:CLSCompliant(true)]

[CLSCompliant(false)]
public sealed class SharingBoundaryAttribute : Attribute
{
    public SharingBoundaryAttribute(params string[] sharingBoundaryNames)
    {
    }
}

class LightweightWebBenchmark
{
    [SharingBoundary("name")]
    public object WebScopeFactory { get; set; }
}

EXPECTED: No warnings
ACTUAL: warning CS3016: Arrays as attribute arguments is not CLS-compliant

If you try to disable the warning by putting [CLSCompliant(false)] on the LightweightWebBenchmark class (or its WebScopeFactory property), you get this error:

warning CS3019: CLS compliance checking will not be performed on 'LightweightWebBenchmark' because it is not visible from outside this assembly

So for code like this it doesn't appear possible to avoid CLS compliance warnings, without disabling CLS compliance for the whole assembly or using specifically ignoring this warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions