Compiler Error CS0181
Attribute constructor parameter has type, which is not a valid attribute parameter type
Example
The following sample generates CS0181:
// CS0181.cs (12,6)
using System;
using System.Runtime.InteropServices;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
unsafe class Attr : Attribute
{
public Attr(delegate*<void> d) {}
}
unsafe class C
{
[UnmanagedCallersOnly]
[Attr(&M1)]
static void M1()
{
}
}
The CLR currently does not allow generic attribute parameter types, so C# does not allow generic attribute parameter types.
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.