public static void AsyncMethodBuilderAttributeTests() { var attr1 = new AsyncMethodBuilderAttribute(null); Assert.Null(attr1.BuilderType); var attr2 = new AsyncMethodBuilderAttribute(typeof(AttributesTests)); Assert.Equal(typeof(AttributesTests), attr2.BuilderType); }
public void AsyncMethodBuilderAttribute_ValueTaskAttributed(Type valueTaskType) { CustomAttributeData cad = valueTaskType.GetTypeInfo().CustomAttributes.Single(attr => attr.AttributeType == typeof(AsyncMethodBuilderAttribute)); Type builderTypeCtorArg = (Type)cad.ConstructorArguments[0].Value; Assert.Equal(typeof(AsyncValueTaskMethodBuilder <>), builderTypeCtorArg); AsyncMethodBuilderAttribute amba = valueTaskType.GetTypeInfo().GetCustomAttribute <AsyncMethodBuilderAttribute>(); Assert.Equal(builderTypeCtorArg, amba.BuilderType); }
public void Ctor_BuilderType_Roundtrip(Type builderType) { var amba = new AsyncMethodBuilderAttribute(builderType); Assert.Same(builderType, amba.BuilderType); }