Exemplo n.º 1
0
        public void AutoProperties()
        {
            var ns   = NamespaceSignature.Parse("MyNamespace");
            var t1   = new GenericParameter(Guid.NewGuid(), "T1");
            var t2   = new GenericParameter(Guid.NewGuid(), "T2");
            var type = TypeSignature.Class("MyType", ns, Accessibility.APublic, true, false, t1, t2);
            var td   = TypeDef.Empty(type)
                       .AddAutoProperty("A", t1, Accessibility.APublic)
                       .AddAutoProperty("B", t2, Accessibility.APublic, isStatic: true)
                       .AddAutoProperty("C", TypeSignature.FromType(typeof(Dictionary <,>)).Specialize(t1, t2), Accessibility.APublic, isStatic: true, isReadOnly: false)
                       .AddAutoProperty("D", TypeReference.Tuple(t1, TypeSignature.String, t2), Accessibility.APublic, isReadOnly: false)
            ;

            cx.AddType(td);
            check.CheckOutput(cx);
        }
Exemplo n.º 2
0
        public static void AddTestExpr(this MetadataContext cx, Expression expr, params ParameterExpression[] parameters)
        {
            var typeCount = cx.DefinedTypes.Count;
            var name      = typeCount < 15 ? ((char)('C' + typeCount)).ToString() : "C" + typeCount;
            var ns        = ((TypeOrNamespace.NamespaceSignatureCase)cx.DefinedTypes.FirstOrDefault()?.Signature.Parent)?.Item ??
                            new NamespaceSignature("NS", NamespaceSignature.Global);
            var type      = TypeSignature.Class(name, ns, Accessibility.APublic);
            var method    = new MethodSignature(type, parameters.Select(p => new MethodParameter(p.Type, p.Name)).ToImmutableArray(), "M", expr.Type(), true, Accessibility.APublic, false, false, false, false, ImmutableArray <GenericParameter> .Empty);
            var methodDef = new MethodDef(method, parameters.ToImmutableArray(), expr);
            var typeDef   = TypeDef.Empty(type).With(members: ImmutableArray.Create <MemberDef>(methodDef));

            cx.AddType(typeDef);
            cx.CommitWaitingTypes();
        }
Exemplo n.º 3
0
 public void StructConstructor()
 {
     cx.AddType(MyStructWithConstructor());
     check.CheckOutput(cx);
 }
Exemplo n.º 4
0
        public void OneEmptyType()
        {
            var type    = TypeSignature.Class("MyType", ns, Accessibility.APublic);
            var typeDef = TypeDef.Empty(type);

            cx.AddType(typeDef);
            check.CheckOutput(cx);
        }