public void DefaultValues() { var sut = new PropertyDeclaration(); Assert.AreEqual(Names.UnknownProperty, sut.Name); Assert.AreEqual(Lists.NewList <IStatement>(), sut.Get); Assert.AreEqual(Lists.NewList <IStatement>(), sut.Set); Assert.AreNotEqual(0, sut.GetHashCode()); Assert.AreNotEqual(1, sut.GetHashCode()); }
public void Equality_Default() { var a = new PropertyDeclaration(); var b = new PropertyDeclaration(); Assert.AreEqual(a, b); Assert.AreEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DifferentType() { var a = new PropertyDeclaration { Name = SomeProperty }; var b = new PropertyDeclaration(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DifferentSet() { var a = new PropertyDeclaration { Set = { new ReturnStatement() } }; var b = new PropertyDeclaration(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public static OverloadsCollection Create(IEmitter emitter, PropertyDeclaration propDeclaration, bool isSetter = false) { string key = propDeclaration.GetHashCode().ToString() + isSetter.GetHashCode().ToString(); if (emitter.OverloadsCache.ContainsKey(key)) { return emitter.OverloadsCache[key]; } return new OverloadsCollection(emitter, propDeclaration, isSetter); }
public static OverloadsCollection Create(IEmitter emitter, PropertyDeclaration propDeclaration, bool isSetter = false) { string key = propDeclaration.GetHashCode().ToString() + isSetter.GetHashCode().ToString(); if (emitter.OverloadsCache.ContainsKey(key)) { return(emitter.OverloadsCache[key]); } return(new OverloadsCollection(emitter, propDeclaration, isSetter)); }
private OverloadsCollection(IEmitter emitter, PropertyDeclaration propDeclaration, bool isSetter) { this.Emitter = emitter; this.Name = propDeclaration.Name; this.JsName = Helpers.GetPropertyRef(propDeclaration, emitter, isSetter, true, true); this.Inherit = !propDeclaration.HasModifier(Modifiers.Static); this.Static = propDeclaration.HasModifier(Modifiers.Static); this.CancelChangeCase = !Helpers.IsFieldProperty(propDeclaration, emitter); this.IsSetter = isSetter; this.Member = this.FindMember(propDeclaration); this.TypeDefinition = this.Member.DeclaringTypeDefinition; this.Type = this.Member.DeclaringType; this.InitMembers(); this.Emitter.OverloadsCache[propDeclaration.GetHashCode().ToString()] = this; }
public void Equality_ReallyEquals() { var a = new PropertyDeclaration { Name = SomeProperty, Get = { new ReturnStatement() }, Set = { new ContinueStatement() } }; var b = new PropertyDeclaration { Name = SomeProperty, Get = { new ReturnStatement() }, Set = { new ContinueStatement() } }; Assert.AreEqual(a, b); Assert.AreEqual(a.GetHashCode(), b.GetHashCode()); }
private OverloadsCollection(IEmitter emitter, PropertyDeclaration propDeclaration, bool isSetter) { this.Emitter = emitter; this.Name = propDeclaration.Name; this.JsName = Helpers.GetPropertyRef(propDeclaration, emitter, isSetter, true, true); this.AltJsName = Helpers.GetPropertyRef(propDeclaration, emitter, !isSetter, true, true); this.Inherit = !propDeclaration.HasModifier(Modifiers.Static); this.Static = propDeclaration.HasModifier(Modifiers.Static); this.CancelChangeCase = !Helpers.IsFieldProperty(propDeclaration, emitter); this.IsSetter = isSetter; this.Member = this.FindMember(propDeclaration); this.TypeDefinition = this.Member.DeclaringTypeDefinition; this.Type = this.Member.DeclaringType; this.InitMembers(); this.Emitter.OverloadsCache[propDeclaration.GetHashCode().ToString() + isSetter.GetHashCode().ToString()] = this; }