Browse Source

Add XML docs & minor optimizations

pull/1161/head
Still Hsu 7 years ago
parent
commit
3ef78a90e0
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
22 changed files with 66 additions and 41 deletions
  1. +0
    -1
      src/Discord.Net.Commands/CommandServiceConfig.cs
  2. +0
    -3
      src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs
  3. +0
    -1
      src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs
  4. +10
    -0
      src/Discord.Net.Core/Extensions/MessageExtensions.cs
  5. +39
    -0
      src/Discord.Net.Core/Extensions/UserExtensions.cs
  6. +2
    -2
      src/Discord.Net.Providers.WS4Net/WS4NetClient.cs
  7. +0
    -1
      src/Discord.Net.Rest/API/Common/EmbedAuthor.cs
  8. +0
    -1
      src/Discord.Net.Rest/API/Common/EmbedFooter.cs
  9. +1
    -2
      src/Discord.Net.Rest/API/Common/EmbedImage.cs
  10. +1
    -2
      src/Discord.Net.Rest/API/Common/EmbedProvider.cs
  11. +1
    -2
      src/Discord.Net.Rest/API/Common/EmbedThumbnail.cs
  12. +1
    -2
      src/Discord.Net.Rest/API/Common/EmbedVideo.cs
  13. +0
    -1
      src/Discord.Net.Rest/API/Rest/UploadFileParams.cs
  14. +0
    -1
      src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs
  15. +0
    -1
      src/Discord.Net.WebSocket/DiscordSocketApiClient.cs
  16. +0
    -1
      src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs
  17. +1
    -5
      test/Discord.Net.Tests/AnalyzerTests/GuildAccessTests.cs
  18. +1
    -2
      test/Discord.Net.Tests/AnalyzerTests/Helpers/DiagnosticVerifier.Helper.cs
  19. +2
    -3
      test/Discord.Net.Tests/AnalyzerTests/Verifiers/DiagnosticVerifier.cs
  20. +1
    -2
      test/Discord.Net.Tests/Net/HttpMixin.cs
  21. +6
    -7
      test/Discord.Net.Tests/Tests.Channels.cs
  22. +0
    -1
      test/Discord.Net.Tests/Tests.Permissions.cs

+ 0
- 1
src/Discord.Net.Commands/CommandServiceConfig.cs View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;

namespace Discord.Commands


+ 0
- 3
src/Discord.Net.Commands/Utilities/QuotationAliasUtils.cs View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;

namespace Discord.Commands
{


+ 0
- 1
src/Discord.Net.Core/Entities/Channels/IAudioChannel.cs View File

@@ -1,5 +1,4 @@
using Discord.Audio;
using System;
using System.Threading.Tasks;

namespace Discord


+ 10
- 0
src/Discord.Net.Core/Extensions/MessageExtensions.cs View File

@@ -1,7 +1,17 @@
namespace Discord
{
/// <summary>
/// Provides extension methods for <see cref="IMessage"/>.
/// </summary>
public static class MessageExtensions
{
/// <summary>
/// Gets a URL that jumps to the message.
/// </summary>
/// <param name="msg">The message to jump to.</param>
/// <returns>
/// A string that contains a URL for jumping to the message in chat.
/// </returns>
public static string GetJumpUrl(this IMessage msg)
{
var channel = msg.Channel;


+ 39
- 0
src/Discord.Net.Core/Extensions/UserExtensions.cs View File

@@ -10,6 +10,19 @@ namespace Discord
/// <summary>
/// Sends a message via DM.
/// </summary>
/// <remarks>
/// This method attempts to send a direct-message to the user.
/// <note type="warning">
/// <para>
/// Please note that this method <strong>will</strong> throw an <see cref="Discord.Net.HttpException"/>
/// if the user cannot receive DMs due to privacy reasons or if the user has the sender blocked.
/// </para>
/// <para>
/// You may want to consider catching for <see cref="Discord.Net.HttpException.DiscordCode"/>
/// <c>50007</c> when using this method.
/// </para>
/// </note>
/// </remarks>
/// <param name="user">The user to send the DM to.</param>
/// <param name="text">The message to be sent.</param>
/// <param name="isTTS">Whether the message should be read aloud by Discord or not.</param>
@@ -30,6 +43,19 @@ namespace Discord
/// <summary>
/// Sends a file to this message channel with an optional caption.
/// </summary>
/// <remarks>
/// This method attempts to send an attachment as a direct-message to the user.
/// <note type="warning">
/// <para>
/// Please note that this method <strong>will</strong> throw an <see cref="Discord.Net.HttpException"/>
/// if the user cannot receive DMs due to privacy reasons or if the user has the sender blocked.
/// </para>
/// <para>
/// You may want to consider catching for <see cref="Discord.Net.HttpException.DiscordCode"/>
/// <c>50007</c> when using this method.
/// </para>
/// </note>
/// </remarks>
/// <param name="user">The user to send the DM to.</param>
/// <param name="stream">The <see cref="Stream"/> of the file to be sent.</param>
/// <param name="filename">The name of the attachment.</param>
@@ -60,6 +86,19 @@ namespace Discord
/// <summary>
/// Sends a file via DM with an optional caption.
/// </summary>
/// <remarks>
/// This method attempts to send an attachment as a direct-message to the user.
/// <note type="warning">
/// <para>
/// Please note that this method <strong>will</strong> throw an <see cref="Discord.Net.HttpException"/>
/// if the user cannot receive DMs due to privacy reasons or if the user has the sender blocked.
/// </para>
/// <para>
/// You may want to consider catching for <see cref="Discord.Net.HttpException.DiscordCode"/>
/// <c>50007</c> when using this method.
/// </para>
/// </note>
/// </remarks>
/// <param name="user">The user to send the DM to.</param>
/// <param name="filePath">The file path of the file.</param>
/// <param name="text">The message to be sent.</param>


+ 2
- 2
src/Discord.Net.Providers.WS4Net/WS4NetClient.cs View File

@@ -1,4 +1,4 @@
using Discord.Net.WebSockets;
using Discord.Net.WebSockets;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -151,7 +151,7 @@ namespace Discord.Net.Providers.WS4Net
}
private void OnBinaryMessage(object sender, DataReceivedEventArgs e)
{
BinaryMessage(e.Data, 0, e.Data.Count()).GetAwaiter().GetResult();
BinaryMessage(e.Data, 0, e.Data.Length).GetAwaiter().GetResult();
}
private void OnConnected(object sender, object e)
{


+ 0
- 1
src/Discord.Net.Rest/API/Common/EmbedAuthor.cs View File

@@ -1,4 +1,3 @@
using System;
using Newtonsoft.Json;

namespace Discord.API


+ 0
- 1
src/Discord.Net.Rest/API/Common/EmbedFooter.cs View File

@@ -1,4 +1,3 @@
using System;
using Newtonsoft.Json;

namespace Discord.API


+ 1
- 2
src/Discord.Net.Rest/API/Common/EmbedImage.cs View File

@@ -1,5 +1,4 @@
#pragma warning disable CS1591
using System;
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API


+ 1
- 2
src/Discord.Net.Rest/API/Common/EmbedProvider.cs View File

@@ -1,5 +1,4 @@
#pragma warning disable CS1591
using System;
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API


+ 1
- 2
src/Discord.Net.Rest/API/Common/EmbedThumbnail.cs View File

@@ -1,5 +1,4 @@
#pragma warning disable CS1591
using System;
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API


+ 1
- 2
src/Discord.Net.Rest/API/Common/EmbedVideo.cs View File

@@ -1,5 +1,4 @@
#pragma warning disable CS1591
using System;
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API


+ 0
- 1
src/Discord.Net.Rest/API/Rest/UploadFileParams.cs View File

@@ -3,7 +3,6 @@ using Discord.Net.Converters;
using Discord.Net.Rest;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;



+ 0
- 1
src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs View File

@@ -69,7 +69,6 @@ namespace Discord.Rest
/// Gets a message from this message channel.
/// </summary>
/// <param name="id">The snowflake identifier of the message.</param>
/// <param name="mode">The <see cref="CacheMode"/> that determines whether the object should be fetched from cache.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents an asynchronous get operation for retrieving the message. The task result contains


+ 0
- 1
src/Discord.Net.WebSocket/DiscordSocketApiClient.cs View File

@@ -1,6 +1,5 @@
#pragma warning disable CS1591
using Discord.API.Gateway;
using Discord.API.Rest;
using Discord.Net.Queue;
using Discord.Net.Rest;
using Discord.Net.WebSockets;


+ 0
- 1
src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs View File

@@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Threading.Tasks;


+ 1
- 5
test/Discord.Net.Tests/AnalyzerTests/GuildAccessTests.cs View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Discord.Analyzers;


+ 1
- 2
test/Discord.Net.Tests/AnalyzerTests/Helpers/DiagnosticVerifier.Helper.cs View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
@@ -7,7 +7,6 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using Discord;
using Discord.Commands;

namespace TestHelper


+ 2
- 3
test/Discord.Net.Tests/AnalyzerTests/Verifiers/DiagnosticVerifier.cs View File

@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
using Xunit;
@@ -104,7 +103,7 @@ namespace TestHelper
/// <param name="expectedResults">Diagnostic Results that should have appeared in the code</param>
private static void VerifyDiagnosticResults(IEnumerable<Diagnostic> actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults)
{
int expectedCount = expectedResults.Count();
int expectedCount = expectedResults.Length;
int actualCount = actualResults.Count();

if (expectedCount != actualCount)


+ 1
- 2
test/Discord.Net.Tests/Net/HttpMixin.cs View File

@@ -9,7 +9,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reactive.Linq;
using System.Reactive.Subjects;
@@ -142,4 +141,4 @@ namespace Discord.Net
return stream.WriteAsync(data, start, length).ToObservable();
}
}
}
}

+ 6
- 7
test/Discord.Net.Tests/Tests.Channels.cs View File

@@ -1,5 +1,4 @@
using Discord.Rest;
using System;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
@@ -171,15 +170,15 @@ namespace Discord
// 2 categories
Assert.Equal(2, categories.Length);

var cat1 = categories.Where(x => x.Name == "cat1").FirstOrDefault();
var cat2 = categories.Where(x => x.Name == "cat2").FirstOrDefault();
var cat1 = categories.FirstOrDefault(x => x.Name == "cat1");
var cat2 = categories.FirstOrDefault(x => x.Name == "cat2");

Assert.NotNull(cat1);
Assert.NotNull(cat2);

// get text1, text2, ensure they have category id == cat1
var text1 = allChannels.Where(x => x.Name == "text1").FirstOrDefault() as RestTextChannel;
var text2 = allChannels.Where(x => x.Name == "text2").FirstOrDefault() as RestTextChannel;
var text1 = allChannels.FirstOrDefault(x => x.Name == "text1") as RestTextChannel;
var text2 = allChannels.FirstOrDefault(x => x.Name == "text2") as RestTextChannel;

Assert.NotNull(text1);
Assert.NotNull(text2);
@@ -197,8 +196,8 @@ namespace Discord
Assert.Equal(text2Cat.Name, cat1.Name);

// do the same for the voice channels
var voice1 = allChannels.Where(x => x.Name == "voice1").FirstOrDefault() as RestVoiceChannel;
var voice3 = allChannels.Where(x => x.Name == "voice3").FirstOrDefault() as RestVoiceChannel;
var voice1 = allChannels.FirstOrDefault(x => x.Name == "voice1") as RestVoiceChannel;
var voice3 = allChannels.FirstOrDefault(x => x.Name == "voice3") as RestVoiceChannel;

Assert.NotNull(voice1);
Assert.NotNull(voice3);


+ 0
- 1
test/Discord.Net.Tests/Tests.Permissions.cs View File

@@ -1,4 +1,3 @@
using System;
using System.Threading.Tasks;
using Xunit;



Loading…
Cancel
Save