Exemplo n.º 1
0
        public void WriteInterfaceDefaultPropertyGetterOnly()
        {
            // Create an interface with a default method
            var iface = SupportTypeBuilder.CreateEmptyInterface("java.code.IMyInterface");
            var prop  = SupportTypeBuilder.CreateProperty(iface, "Value", "int", options);

            prop.Getter.IsInterfaceDefaultMethod = true;
            prop.Setter = null;

            iface.Properties.Add(prop);

            iface.Validate(options, new GenericParameterDefinitionList(), new CodeGeneratorContext());

            generator.WriteInterfaceDeclaration(iface, string.Empty);

            Assert.AreEqual(GetTargetedExpected(nameof(WriteInterfaceDefaultPropertyGetterOnly)), writer.ToString().NormalizeLineEndings());
        }
Exemplo n.º 2
0
        public void WriteStaticInterfaceProperty()
        {
            // Create an interface with a static property
            var iface = SupportTypeBuilder.CreateEmptyInterface("java.code.IMyInterface");
            var prop  = SupportTypeBuilder.CreateProperty(iface, "Value", "int", options);

            prop.Getter.IsStatic  = true;
            prop.Getter.IsVirtual = false;
            prop.Setter.IsStatic  = true;
            prop.Setter.IsVirtual = false;

            iface.Properties.Add(prop);

            iface.Validate(options, new GenericParameterDefinitionList(), new CodeGeneratorContext());

            generator.WriteInterfaceDeclaration(iface, string.Empty, new GenerationInfo(null, null, null));

            Assert.AreEqual(GetTargetedExpected(nameof(WriteStaticInterfaceProperty)), writer.ToString().NormalizeLineEndings());
        }
Exemplo n.º 3
0
        public void FixProtectedProperty()
        {
            var klass = CreateSealedClass();

            var method = SupportTypeBuilder.CreateProperty(klass, "Handle", "int", options);

            klass.Properties.Add(method);

            method.Getter.Visibility = "protected";
            method.Getter.IsOverride = false;

            method.Setter.Visibility = "protected";
            method.Setter.IsOverride = false;

            SealedProtectedFixups.Fixup(new [] { (GenBase)klass }.ToList());

            Assert.AreEqual("private", method.Getter.Visibility);
            Assert.AreEqual("private", method.Setter.Visibility);
        }
Exemplo n.º 4
0
        public void WriteKotlinUnsignedArrayTypePropertiesClass()
        {
            var @class = new TestClass("Object", "java.code.MyClass");

            @class.Properties.Add(SupportTypeBuilder.CreateProperty(@class, "UIntProp", "uint[]", options, false, false));
            @class.Properties.Add(SupportTypeBuilder.CreateProperty(@class, "UShortProp", "ushort[]", options, false, false));
            @class.Properties.Add(SupportTypeBuilder.CreateProperty(@class, "ULongProp", "ulong[]", options, false, false));
            @class.Properties.Add(SupportTypeBuilder.CreateProperty(@class, "UByteProp", "ubyte[]", options, false, false));

            // Kotlin methods with unsigned types are name-mangled and don't support virtual
            foreach (var m in @class.Properties)
            {
                m.Getter.IsVirtual = false;
                m.Setter.IsVirtual = false;
            }

            generator.Context.ContextTypes.Push(@class);
            generator.WriteClass(@class, string.Empty, new GenerationInfo("", "", "MyAssembly"));
            generator.Context.ContextTypes.Pop();

            Assert.AreEqual(GetTargetedExpected(nameof(WriteKotlinUnsignedArrayTypePropertiesClass)), writer.ToString().NormalizeLineEndings());
        }