Create() 공개 메소드

public Create ( Microsoft.CodeAnalysis.CSharp.Syntax.FieldDeclarationSyntax mixinFieldDeclaration ) : MixinReference
mixinFieldDeclaration Microsoft.CodeAnalysis.CSharp.Syntax.FieldDeclarationSyntax
리턴 MixinReference
        public void CreateMixinFromFieldDefinition_Error()
        {
            WithSourceFiles(Files.Person);
            var personClass = CreateClass(nameof(Person));
            var mixinField = personClass.SourceCode.FindMixinReference("_name");

            var mixinFactory = new MixinReferenceFactory(Semantic);
            var mixin = mixinFactory.Create(mixinField);
            // Assert: type could not be resolved and null should be returned instead
            Assert.IsNull(mixin);
        }
        public void CreateMixinFromBaseList_Success()
        {
            WithSourceFiles(Files.NotCompilable, Files.Mixin);
            var personClass = CreateClass("SimpleChildClassWithInterface");
            var baseClass = (SimpleBaseTypeSyntax)personClass.SourceCode.BaseList.Types[0];

            var mixinFactory = new MixinReferenceFactory(Semantic);
            var mixin = mixinFactory.Create(baseClass);

            Assert.IsNotNull(mixin);
        }
        public void CreateMixinFromFieldDefinition_Success()
        {
            WithSourceFiles(Files.Person, Files.Name);
            var personClass = CreateClass(nameof(Person));
            var mixinField = personClass.SourceCode.FindMixinReference("_name");

            var mixinFactory = new MixinReferenceFactory(Semantic);
            var mixin = mixinFactory.Create(mixinField);

            Assert.AreEqual("_name", mixin.Name);
            Assert.AreEqual(3, mixin.Class.Properties.Count());
        }
        public void ClassWithNativeFields_CanExecuteMixinCommand_CannotExecute()
        {
            WithSourceFiles(Files.Person);
            var person = CreateClass(nameof(PersonWithNativeTypes));
            var fieldDeclarations = person.SourceCode.DescendantNodes().OfType<FieldDeclarationSyntax>();

            var mixinFactory = new MixinReferenceFactory(Semantic);

            foreach (var fieldDeclaration in fieldDeclarations)
            {
                var mixin = mixinFactory.Create(fieldDeclaration);
                var mixinCommand = new IncludeMixinCommand(mixin);
                Assert.IsFalse(mixinCommand.CanExecute(person));
            }
        }