private void CompareReturnType() { if (ReferenceType.ReturnType.GetCompareableName() != NewType.ReturnType.GetCompareableName()) { ComparerResult.AddChangedProperty("Return Type", ReferenceType.ReturnType.GetCompareableName(), NewType.ReturnType.GetCompareableName(), Severity.Error); } }
private void CompareDefaultValue() { if (!Equals(ReferenceType.RawDefaultValue, NewType.RawDefaultValue)) { ComparerResult.AddChangedProperty("Default Value", (ReferenceType.RawDefaultValue ?? "null").ToString(), (NewType.RawDefaultValue ?? "null").ToString(), Severities.DefaultValueChanged); } }
private void AddToResultIfNotEqual(string propertyName, string referenceValue, string newValue, Severity severity) { if (referenceValue != newValue) { ComparerResult.AddChangedProperty(propertyName, referenceValue, newValue, severity); } }
private void CompareName() { if (ReferenceType.Name != NewType.Name) { ComparerResult.AddChangedProperty("Name", ReferenceType.Name, NewType.Name, Severities.ParameterNameChanged); } }
private void CompareName() { if (ReferenceType.Name != NewType.Name) { ComparerResult.AddChangedProperty("Name", ReferenceType.Name, NewType.Name, Severity.Error); } }
private void CompareDefaultValue() { if (!Equals(ReferenceType.RawDefaultValue, NewType.RawDefaultValue)) { ComparerResult.AddChangedProperty("Default Value", ReferenceType.RawDefaultValue.ToString(), NewType.RawDefaultValue.ToString(), Severity.Error); } }
public void When_passing_changed_property_xml_should_contain_it() { IComparerResult result = new ComparerResult(ResultContext.Assembly, "Assembly"); result.AddChangedProperty("PropName", "old", "new", Severity.Error); XElement xml = XmlGenerator.GenerateXml(result); XElement sut = xml.Element(ChangedElement).Element(ChangedAttribute); Assert.AreEqual("PropName", sut.Attribute("Name").Value); StringAssert.AreEqualIgnoringCase(Severity.Error.ToString(), sut.Attribute("Severity").Value); Assert.AreEqual("old", sut.Attribute("ReferenceValue").Value); Assert.AreEqual("new", sut.Attribute("NewValue").Value); }
public override IComparerResult Compare() { ComparerContext.LogDetail(string.Format("Comparing event '{0}'", ReferenceType)); if (ReferenceType.EventHandlerType.GetCompareableName() != NewType.EventHandlerType.GetCompareableName()) { ComparerResult.AddChangedProperty("Type", ReferenceType.EventHandlerType.GetCompareableName(), NewType.EventHandlerType.GetCompareableName(), Severity.Error); } bool referenceStatic = (ReferenceType.AddMethod != null && ReferenceType.AddMethod.IsStatic) || (ReferenceType.RaiseMethod != null && ReferenceType.RaiseMethod.IsStatic); bool newStatic = (NewType.AddMethod != null && NewType.AddMethod.IsStatic) || (NewType.RaiseMethod != null && NewType.RaiseMethod.IsStatic); if (referenceStatic != newStatic) { ComparerResult.AddChangedFlag("Static", referenceStatic, Severity.Error); } return(ComparerResult); }
public override IComparerResult Compare() { ComparerContext.LogDetail(string.Format("Comparing field '{0}'", ReferenceType)); if (ReferenceType.FieldType.GetCompareableName() != NewType.FieldType.GetCompareableName()) { ComparerResult.AddChangedProperty("Type", ReferenceType.FieldType.GetCompareableName(), NewType.FieldType.GetCompareableName(), Severity.Error); } if (ReferenceType.IsStatic != NewType.IsStatic) { ComparerResult.AddChangedFlag("Static", ReferenceType.IsStatic, Severity.Error); } if (ReferenceType.IsStatic && NewType.IsStatic && ReferenceType.FieldType.IsEnum) { // compare numeric enum values object referenceValue = ReferenceType.GetRawConstantValue(); object newValue = NewType.GetRawConstantValue(); if (Convert.ToInt32(referenceValue) != Convert.ToInt32(newValue)) { ComparerResult.AddChangedProperty("Value", referenceValue.ToString(), newValue.ToString(), Severity.Error); } } return(ComparerResult); }
public override IComparerResult Compare() { ComparerContext.LogDetail(string.Format("Comparing property '{0}'", ReferenceType)); if (ReferenceType.PropertyType.GetCompareableName() != NewType.PropertyType.GetCompareableName()) { ComparerResult.AddChangedProperty("Type", ReferenceType.PropertyType.GetCompareableName(), NewType.PropertyType.GetCompareableName(), Severity.Error); } if (ReferenceType.CanWrite != NewType.CanWrite) { ComparerResult.AddChangedFlag("Setter", ReferenceType.CanWrite, Severity.Error); } if (ReferenceType.CanRead != NewType.CanRead) { ComparerResult.AddChangedFlag("Getter", ReferenceType.CanRead, Severity.Error); } bool referenceStatic = (ReferenceType.GetMethod != null && ReferenceType.GetMethod.IsStatic) || (ReferenceType.SetMethod != null && ReferenceType.SetMethod.IsStatic); bool newStatic = (NewType.GetMethod != null && NewType.GetMethod.IsStatic) || (NewType.SetMethod != null && NewType.SetMethod.IsStatic); if (referenceStatic != newStatic) { ComparerResult.AddChangedFlag("Static", referenceStatic, Severity.Error); } return(ComparerResult); }
public Builder Property(Severity severity = Severity.Error, string name = "Name", string refValue = "ref", string newValue = "new") { _comparerResult.AddChangedProperty(name, refValue, newValue, severity); return(this); }