Browse Source

Added xmldoc and minor optimizations

pull/2347/head
Misha133 3 years ago
parent
commit
8ae3beccbc
9 changed files with 181 additions and 13 deletions
  1. +15
    -1
      src/Discord.Net.Core/Entities/Messages/Embed.cs
  2. +15
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs
  3. +61
    -5
      src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs
  4. +15
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedField.cs
  5. +15
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs
  6. +15
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedImage.cs
  7. +15
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedProvider.cs
  8. +15
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedThumbnail.cs
  9. +15
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedVideo.cs

+ 15
- 1
src/Discord.Net.Core/Entities/Messages/Embed.cs View File

@@ -102,12 +102,26 @@ namespace Discord
public static bool operator !=(Embed left, Embed right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="Embed"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="Embed"/>, <see cref="Equals(Embed)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="Embed"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as Embed);
=> obj is Embed embed && Equals(embed);

/// <summary>
/// Determines whether the specified <see cref="Embed"/> is equals to the current <see cref="Embed"/>
/// </summary>
/// <param name="embed">The <see cref="Embed"/> to compare with the current <see cref="Embed"/></param>
/// <returns></returns>
public bool Equals(Embed embed)
=> GetHashCode() == embed.GetHashCode();

/// <inheritdoc />
public override int GetHashCode()
{
unchecked


+ 15
- 1
src/Discord.Net.Core/Entities/Messages/EmbedAuthor.cs View File

@@ -50,12 +50,26 @@ namespace Discord
public static bool operator !=(EmbedAuthor? left, EmbedAuthor? right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedAuthor"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedAuthor"/>, <see cref="Equals(EmbedAuthor)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedAuthor"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedAuthor?);
=> obj is EmbedAuthor embedAuthor && Equals(embedAuthor);

/// <summary>
/// Determines whether the specified <see cref="EmbedAuthor"/> is equals to the current <see cref="EmbedAuthor"/>
/// </summary>
/// <param name="embedAuthor">The <see cref="EmbedAuthor"/> to compare with the current <see cref="EmbedAuthor"/></param>
/// <returns></returns>
public bool Equals(EmbedAuthor embedAuthor)
=> GetHashCode() == embedAuthor.GetHashCode();

/// <inheritdoc />
public override int GetHashCode()
=> (Name, Url, IconUrl).GetHashCode();
}


+ 61
- 5
src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs View File

@@ -489,9 +489,22 @@ namespace Discord
public static bool operator !=(EmbedBuilder left, EmbedBuilder right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedBuilder"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedBuilder"/>, <see cref="Equals(EmbedBuilder)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedBuilder"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedBuilder);
=> obj is EmbedBuilder embedBuilder && Equals(embedBuilder);

/// <summary>
/// Determines whether the specified <see cref="EmbedBuilder"/> is equals to the current <see cref="EmbedBuilder"/>
/// </summary>
/// <param name="embedBuilder">The <see cref="EmbedBuilder"/> to compare with the current <see cref="EmbedBuilder"/></param>
/// <returns></returns>
public bool Equals(EmbedBuilder embedBuilder)
{
if (Fields.Count != embedBuilder.Fields.Count)
@@ -512,6 +525,7 @@ namespace Discord
&& Url == embedBuilder?.Url;
}

/// <inheritdoc />
public override int GetHashCode() => base.GetHashCode();
}

@@ -637,14 +651,28 @@ namespace Discord
public static bool operator !=(EmbedFieldBuilder left, EmbedFieldBuilder right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedFieldBuilder"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedFieldBuilder"/>, <see cref="Equals(EmbedFieldBuilder)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedFieldBuilder"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedFieldBuilder);
=> obj is EmbedFieldBuilder embedFieldBuilder && Equals(embedFieldBuilder);

/// <summary>
/// Determines whether the specified <see cref="EmbedFieldBuilder"/> is equals to the current <see cref="EmbedFieldBuilder"/>
/// </summary>
/// <param name="embedFieldBuilder">The <see cref="EmbedFieldBuilder"/> to compare with the current <see cref="EmbedFieldBuilder"/></param>
/// <returns></returns>
public bool Equals(EmbedFieldBuilder embedFieldBuilder)
=> _name == embedFieldBuilder?._name
&& _value == embedFieldBuilder?._value
&& IsInline == embedFieldBuilder?.IsInline;
&& IsInline == embedFieldBuilder?.IsInline;

/// <inheritdoc />
public override int GetHashCode() => base.GetHashCode();
}

@@ -754,14 +782,28 @@ namespace Discord
public static bool operator !=(EmbedAuthorBuilder left, EmbedAuthorBuilder right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedAuthorBuilder"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedAuthorBuilder"/>, <see cref="Equals(EmbedAuthorBuilder)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedAuthorBuilder"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedAuthorBuilder);
=> obj is EmbedAuthorBuilder embedAuthorBuilder && Equals(embedAuthorBuilder);

/// <summary>
/// Determines whether the specified <see cref="EmbedAuthorBuilder"/> is equals to the current <see cref="EmbedAuthorBuilder"/>
/// </summary>
/// <param name="embedAuthorBuilder">The <see cref="EmbedAuthorBuilder"/> to compare with the current <see cref="EmbedAuthorBuilder"/></param>
/// <returns></returns>
public bool Equals(EmbedAuthorBuilder embedAuthorBuilder)
=> _name == embedAuthorBuilder?._name
&& Url == embedAuthorBuilder?.Url
&& IconUrl == embedAuthorBuilder?.IconUrl;

/// <inheritdoc />
public override int GetHashCode() => base.GetHashCode();
}

@@ -851,13 +893,27 @@ namespace Discord
public static bool operator !=(EmbedFooterBuilder left, EmbedFooterBuilder right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedFooterBuilder"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedFooterBuilder"/>, <see cref="Equals(EmbedFooterBuilder)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedFooterBuilder"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedFooterBuilder);
=> obj is EmbedFooterBuilder embedFooterBuilder && Equals(embedFooterBuilder);

/// <summary>
/// Determines whether the specified <see cref="EmbedFooterBuilder"/> is equals to the current <see cref="EmbedFooterBuilder"/>
/// </summary>
/// <param name="embedFooterBuilder">The <see cref="EmbedFooterBuilder"/> to compare with the current <see cref="EmbedFooterBuilder"/></param>
/// <returns></returns>
public bool Equals(EmbedFooterBuilder embedFooterBuilder)
=> _text == embedFooterBuilder?._text
&& IconUrl == embedFooterBuilder?.IconUrl;

/// <inheritdoc />
public override int GetHashCode() => base.GetHashCode();
}
}

+ 15
- 1
src/Discord.Net.Core/Entities/Messages/EmbedField.cs View File

@@ -45,12 +45,26 @@ namespace Discord
public static bool operator !=(EmbedField? left, EmbedField? right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedField"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedField"/>, <see cref="Equals(EmbedField)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current object</param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedField?);
=> obj is EmbedField embedField && Equals(embedField);

/// <summary>
/// Determines whether the specified <see cref="EmbedField"/> is equals to the current <see cref="EmbedField"/>
/// </summary>
/// <param name="embedField"></param>
/// <returns></returns>
public bool Equals(EmbedField embedField)
=> GetHashCode() == embedField.GetHashCode();

/// <inheritdoc />
public override int GetHashCode()
=> (Name, Value, Inline).GetHashCode();
}


+ 15
- 1
src/Discord.Net.Core/Entities/Messages/EmbedFooter.cs View File

@@ -52,12 +52,26 @@ namespace Discord
public static bool operator !=(EmbedFooter? left, EmbedFooter? right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedFooter"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedFooter"/>, <see cref="Equals(EmbedFooter)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedFooter"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedFooter?);
=> obj is EmbedFooter embedFooter && Equals(embedFooter);

/// <summary>
/// Determines whether the specified <see cref="EmbedFooter"/> is equals to the current <see cref="EmbedFooter"/>
/// </summary>
/// <param name="embedFooter">The <see cref="EmbedFooter"/> to compare with the current <see cref="EmbedFooter"/></param>
/// <returns></returns>
public bool Equals(EmbedFooter embedFooter)
=> GetHashCode() == embedFooter.GetHashCode();

/// <inheritdoc />
public override int GetHashCode()
=> (Text, IconUrl, ProxyUrl).GetHashCode();
}


+ 15
- 1
src/Discord.Net.Core/Entities/Messages/EmbedImage.cs View File

@@ -62,12 +62,26 @@ namespace Discord
public static bool operator !=(EmbedImage? left, EmbedImage? right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedImage"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedImage"/>, <see cref="Equals(EmbedImage)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedImage"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedImage?);
=> obj is EmbedImage embedImage && Equals(embedImage);

/// <summary>
/// Determines whether the specified <see cref="EmbedImage"/> is equals to the current <see cref="EmbedImage"/>
/// </summary>
/// <param name="embedImage">The <see cref="EmbedImage"/> to compare with the current <see cref="EmbedImage"/></param>
/// <returns></returns>
public bool Equals(EmbedImage embedImage)
=> GetHashCode() == embedImage.GetHashCode();

/// <inheritdoc />
public override int GetHashCode()
=> (Height, Width, Url, ProxyUrl).GetHashCode();
}


+ 15
- 1
src/Discord.Net.Core/Entities/Messages/EmbedProvider.cs View File

@@ -44,12 +44,26 @@ namespace Discord
public static bool operator !=(EmbedProvider? left, EmbedProvider? right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedProvider"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedProvider"/>, <see cref="Equals(EmbedProvider)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedProvider"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedProvider?);
=> obj is EmbedProvider embedProvider && Equals(embedProvider);

/// <summary>
/// Determines whether the specified <see cref="EmbedProvider"/> is equals to the current <see cref="EmbedProvider"/>
/// </summary>
/// <param name="embedProvider">The <see cref="EmbedProvider"/> to compare with the current <see cref="EmbedProvider"/></param>
/// <returns></returns>
public bool Equals(EmbedProvider embedProvider)
=> GetHashCode() == embedProvider.GetHashCode();

/// <inheritdoc />
public override int GetHashCode()
=> (Name, Url).GetHashCode();
}


+ 15
- 1
src/Discord.Net.Core/Entities/Messages/EmbedThumbnail.cs View File

@@ -62,12 +62,26 @@ namespace Discord
public static bool operator !=(EmbedThumbnail? left, EmbedThumbnail? right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedThumbnail"/>.
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedThumbnail"/>, <see cref="Equals(EmbedThumbnail)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedThumbnail"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedThumbnail?);
=> obj is EmbedThumbnail embedThumbnail && Equals(embedThumbnail);

/// <summary>
/// Determines whether the specified <see cref="EmbedThumbnail"/> is equals to the current <see cref="EmbedThumbnail"/>
/// </summary>
/// <param name="embedThumbnail">The <see cref="EmbedThumbnail"/> to compare with the current <see cref="EmbedThumbnail"/></param>
/// <returns></returns>
public bool Equals(EmbedThumbnail embedThumbnail)
=> GetHashCode() == embedThumbnail.GetHashCode();

/// <inheritdoc />
public override int GetHashCode()
=> (Width, Height, Url, ProxyUrl).GetHashCode();
}


+ 15
- 1
src/Discord.Net.Core/Entities/Messages/EmbedVideo.cs View File

@@ -56,12 +56,26 @@ namespace Discord
public static bool operator !=(EmbedVideo? left, EmbedVideo? right)
=> !(left == right);

/// <summary>
/// Determines whether the specified object is equals to the current <see cref="EmbedVideo"/>. ///
/// </summary>
/// <remarks>
/// If the object passes is an <see cref="EmbedVideo"/>, <see cref="Equals(EmbedVideo)"/> will be called to compare the 2 instances
/// </remarks>
/// <param name="obj">The object to compare with the current <see cref="EmbedVideo"/></param>
/// <returns></returns>
public override bool Equals(object obj)
=> obj is not null && GetType() == obj.GetType() && Equals(obj as EmbedVideo?);
=> obj is EmbedVideo embedVideo && Equals(embedVideo);

/// <summary>
/// Determines whether the specified <see cref="EmbedVideo"/> is equals to the current <see cref="EmbedVideo"/>
/// </summary>
/// <param name="embedVideo">The <see cref="EmbedVideo"/> to compare with the current <see cref="EmbedVideo"/></param>
/// <returns></returns>
public bool Equals(EmbedVideo embedVideo)
=> GetHashCode() == embedVideo.GetHashCode();

/// <inheritdoc />
public override int GetHashCode()
=> (Width, Height, Url).GetHashCode();
}


Loading…
Cancel
Save