コード例 #1
0
        public void DefaultValues()
        {
            var sut = new MethodDeclaration();

            Assert.AreEqual(Names.UnknownMethod, sut.Name);
            Assert.False(sut.IsEntryPoint);
            Assert.AreEqual(Lists.NewList <IMethodDeclaration>(), sut.Body);
            Assert.AreNotEqual(0, sut.GetHashCode());
            Assert.AreNotEqual(1, sut.GetHashCode());
        }
コード例 #2
0
        public void Equality_Default()
        {
            var a = new MethodDeclaration();
            var b = new MethodDeclaration();

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #3
0
        public void Equality_DifferentBody()
        {
            var a = new MethodDeclaration();

            a.Body.Add(new ContinueStatement());
            var b = new MethodDeclaration();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #4
0
        public void Equality_DifferentEntryPoint()
        {
            var a = new MethodDeclaration {
                IsEntryPoint = true
            };
            var b = new MethodDeclaration();

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #5
0
        public static OverloadsCollection Create(IEmitter emitter, MethodDeclaration methodDeclaration)
        {
            string key = methodDeclaration.GetHashCode().ToString();
            if (emitter.OverloadsCache.ContainsKey(key))
            {
                return emitter.OverloadsCache[key];
            }

            return new OverloadsCollection(emitter, methodDeclaration);
        }
コード例 #6
0
        public static OverloadsCollection Create(IEmitter emitter, MethodDeclaration methodDeclaration)
        {
            string key = methodDeclaration.GetHashCode().ToString();

            if (emitter.OverloadsCache.ContainsKey(key))
            {
                return(emitter.OverloadsCache[key]);
            }

            return(new OverloadsCollection(emitter, methodDeclaration));
        }
コード例 #7
0
 private OverloadsCollection(IEmitter emitter, MethodDeclaration methodDeclaration)
 {
     this.Emitter        = emitter;
     this.Name           = methodDeclaration.Name;
     this.JsName         = this.Emitter.GetEntityName(methodDeclaration, false, true);
     this.Inherit        = !methodDeclaration.HasModifier(Modifiers.Static);
     this.Static         = methodDeclaration.HasModifier(Modifiers.Static);
     this.Member         = this.FindMember(methodDeclaration);
     this.TypeDefinition = this.Member.DeclaringTypeDefinition;
     this.Type           = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.OverloadsCache[methodDeclaration.GetHashCode().ToString()] = this;
 }
コード例 #8
0
 private OverloadsCollection(IEmitter emitter, MethodDeclaration methodDeclaration)
 {
     this.Emitter = emitter;
     this.Name = methodDeclaration.Name;
     this.JsName = this.Emitter.GetEntityName(methodDeclaration, false, true);
     this.Inherit = !methodDeclaration.HasModifier(Modifiers.Static);
     this.Static = methodDeclaration.HasModifier(Modifiers.Static);
     this.Member = this.FindMember(methodDeclaration);
     this.TypeDefinition = this.Member.DeclaringTypeDefinition;
     this.Type = this.Member.DeclaringType;
     this.InitMembers();
     this.Emitter.OverloadsCache[methodDeclaration.GetHashCode().ToString()] = this;
 }
コード例 #9
0
        public void Equality_DifferentName()
        {
            var a = new MethodDeclaration
            {
                Name = _mA
            };
            var b = new MethodDeclaration
            {
                Name = _mB
            };

            Assert.AreNotEqual(a, b);
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
コード例 #10
0
        public void Equality_ReallyTheSame()
        {
            var a = new MethodDeclaration
            {
                Name         = _mA,
                IsEntryPoint = true,
                Body         = { new ReturnStatement() }
            };
            var b = new MethodDeclaration
            {
                Name         = _mA,
                IsEntryPoint = true,
                Body         = { new ReturnStatement() }
            };

            Assert.AreEqual(a, b);
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }