Skip to content

Commit

Permalink
revert using Equ for equality
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparnagy committed Jul 9, 2019
1 parent b40219d commit 4c0806b
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
<AdditionalDeveroomDependencies Include="Utf8Json.dll" />
<AdditionalDeveroomDependencies Include="System.Threading.Tasks.Extensions.dll" />
<AdditionalDeveroomDependencies Include="System.IO.Abstractions.dll" />
<AdditionalDeveroomDependencies Include="Equ.dll" />
</ItemGroup>

<Import Project="..\Deveroom.VisualStudio.SpecFlowConnector.V1\DeploymentAssets.props" />
Expand Down
35 changes: 32 additions & 3 deletions Deveroom.VisualStudio/Configuration/DeveroomConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using Equ;

namespace Deveroom.VisualStudio.Configuration
{
public class DeveroomConfiguration: MemberwiseEquatable<DeveroomConfiguration>
public class DeveroomConfiguration
{
[MemberwiseEqualityIgnore]
public DateTime ConfigurationChangeTime { get; set; } = DateTime.MinValue;

public string ConfigurationBaseFolder { get; set; }
Expand Down Expand Up @@ -38,5 +36,36 @@ public void CheckConfiguration()
Traceability.CheckConfiguration();
}

#region Equality

protected bool Equals(DeveroomConfiguration other)
{
return string.Equals(ConfigurationBaseFolder, other.ConfigurationBaseFolder) && Equals(SpecFlow, other.SpecFlow) && Equals(Traceability, other.Traceability) && ProcessorArchitecture == other.ProcessorArchitecture && DebugConnector == other.DebugConnector && string.Equals(DefaultFeatureLanguage, other.DefaultFeatureLanguage) && string.Equals(ConfiguredBindingCulture, other.ConfiguredBindingCulture);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((DeveroomConfiguration) obj);
}

public override int GetHashCode()
{
unchecked
{
var hashCode = (ConfigurationBaseFolder != null ? ConfigurationBaseFolder.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (SpecFlow != null ? SpecFlow.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Traceability != null ? Traceability.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (int) ProcessorArchitecture;
hashCode = (hashCode * 397) ^ DebugConnector.GetHashCode();
hashCode = (hashCode * 397) ^ (DefaultFeatureLanguage != null ? DefaultFeatureLanguage.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (ConfiguredBindingCulture != null ? ConfiguredBindingCulture.GetHashCode() : 0);
return hashCode;
}
}

#endregion
}
}
33 changes: 31 additions & 2 deletions Deveroom.VisualStudio/Configuration/SpecFlowConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
using System.Text.RegularExpressions;
using Deveroom.VisualStudio.Common;
using Deveroom.VisualStudio.ProjectSystem.Settings;
using Equ;

namespace Deveroom.VisualStudio.Configuration
{
public class SpecFlowConfiguration: MemberwiseEquatable<SpecFlowConfiguration>
public class SpecFlowConfiguration
{
public bool? IsSpecFlowProject { get; set; }

Expand All @@ -28,5 +27,35 @@ public void CheckConfiguration()
if (Version != null && !Regex.IsMatch(Version, @"^(?:\.?[0-9]+){2,}(?:\-[\-a-z0-9]*)?$"))
throw new DeveroomConfigurationException("'specFlow/version' was not in a correct format");
}

#region Equality

protected bool Equals(SpecFlowConfiguration other)
{
return IsSpecFlowProject == other.IsSpecFlowProject && string.Equals(Version, other.Version) && string.Equals(GeneratorFolder, other.GeneratorFolder) && string.Equals(ConfigFilePath, other.ConfigFilePath) && Equals(Traits, other.Traits);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((SpecFlowConfiguration) obj);
}

public override int GetHashCode()
{
unchecked
{
var hashCode = IsSpecFlowProject.GetHashCode();
hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (GeneratorFolder != null ? GeneratorFolder.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (ConfigFilePath != null ? ConfigFilePath.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Traits != null ? Traits.GetHashCode() : 0);
return hashCode;
}
}

#endregion
}
}
31 changes: 29 additions & 2 deletions Deveroom.VisualStudio/Configuration/TagLinkConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Deveroom.VisualStudio.Common;
using Equ;

namespace Deveroom.VisualStudio.Configuration
{
public class TagLinkConfiguration : MemberwiseEquatable<TagLinkConfiguration>
public class TagLinkConfiguration
{
public string TagPattern { get; set; }
public string UrlTemplate { get; set; }
Expand Down Expand Up @@ -39,5 +38,33 @@ public void CheckConfiguration()
throw new DeveroomConfigurationException($"Invalid regular expression '{TagPattern}' was specified as 'traceability/tagLinks[]/tagPattern': {e.Message}");
}
}

#region Equality

protected bool Equals(TagLinkConfiguration other)
{
return string.Equals(TagPattern, other.TagPattern) && string.Equals(UrlTemplate, other.UrlTemplate) && Equals(ResolvedTagPattern, other.ResolvedTagPattern);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((TagLinkConfiguration) obj);
}

public override int GetHashCode()
{
unchecked
{
var hashCode = (TagPattern != null ? TagPattern.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (UrlTemplate != null ? UrlTemplate.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (ResolvedTagPattern != null ? ResolvedTagPattern.GetHashCode() : 0);
return hashCode;
}
}

#endregion
}
}
25 changes: 23 additions & 2 deletions Deveroom.VisualStudio/Configuration/TraceabilityConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Equ;

namespace Deveroom.VisualStudio.Configuration
{
public class TraceabilityConfiguration : MemberwiseEquatable<TraceabilityConfiguration>
public class TraceabilityConfiguration
{
public TagLinkConfiguration[] TagLinks { get; set; } = new TagLinkConfiguration[0];

Expand All @@ -25,5 +24,27 @@ public void CheckConfiguration()
tagLinkConfiguration.CheckConfiguration();
}
}

#region Equality

protected bool Equals(TraceabilityConfiguration other)
{
return Equals(TagLinks, other.TagLinks);
}

public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((TraceabilityConfiguration) obj);
}

public override int GetHashCode()
{
return (TagLinks != null ? TagLinks.GetHashCode() : 0);
}

#endregion
}
}
1 change: 0 additions & 1 deletion Deveroom.VisualStudio/Deveroom.VisualStudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<PackageReference Include="System.IO.Abstractions" Version="4.2.10" />
<PackageReference Include="Microsoft.Composition" Version="1.0.31" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Equ" Version="2.1.0-deveroomhotfix" />

<PackageReference Include="Microsoft.VisualStudio.Text.Data" Version="15.6.27740" />
<PackageReference Include="Microsoft.VisualStudio.Text.Logic" Version="15.6.27740" />
Expand Down

0 comments on commit 4c0806b

Please sign in to comment.