Added missing ToString and DebuggerDisplays

This commit is contained in:
RogueException
2016-10-04 16:41:40 -03:00
parent e70d478759
commit 7df38fea3a
28 changed files with 75 additions and 27 deletions

View File

@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Model = Discord.API.Channel;
namespace Discord.Rest
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class RestChannel : RestEntity<ulong>, IChannel, IUpdateable
{
internal RestChannel(BaseDiscordClient discord, ulong id)

View File

@@ -76,7 +76,6 @@ namespace Discord.Rest
public override string ToString() => $"@{Recipient}";
private string DebuggerDisplay => $"@{Recipient} ({Id}, DM)";
//IDMChannel
IUser IDMChannel.Recipient => Recipient;

View File

@@ -86,6 +86,9 @@ namespace Discord.Rest
public IDisposable EnterTypingState()
=> ChannelHelper.EnterTypingState(this, Discord);
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id}, Group)";
//ISocketPrivateChannel
IReadOnlyCollection<RestUser> IRestPrivateChannel.Recipients => Recipients;

View File

@@ -2,14 +2,12 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Model = Discord.API.Channel;
namespace Discord.Rest
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class RestGuildChannel : RestChannel, IGuildChannel, IUpdateable
{
private ImmutableArray<Overwrite> _overwrites;
@@ -117,7 +115,9 @@ namespace Discord.Rest
=> await ChannelHelper.GetInvitesAsync(this, Discord);
public async Task<RestInviteMetadata> CreateInviteAsync(int? maxAge = 3600, int? maxUses = null, bool isTemporary = true)
=> await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary);
public override string ToString() => Name;
//IGuildChannel
async Task<IReadOnlyCollection<IInviteMetadata>> IGuildChannel.GetInvitesAsync()
=> await GetInvitesAsync();

View File

@@ -1,7 +1,6 @@
using Discord.API.Rest;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -67,6 +66,8 @@ namespace Discord.Rest
public IDisposable EnterTypingState()
=> ChannelHelper.EnterTypingState(this, Discord);
private string DebuggerDisplay => $"{Name} ({Id}, Text)";
//IGuildChannel
async Task<IGuildUser> IGuildChannel.GetUserAsync(ulong id, CacheMode mode)
{

View File

@@ -2,7 +2,6 @@
using Discord.Audio;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
@@ -37,6 +36,8 @@ namespace Discord.Rest
public Task ModifyAsync(Action<ModifyVoiceChannelParams> func)
=> ChannelHelper.ModifyAsync(this, Discord, func);
private string DebuggerDisplay => $"{Name} ({Id}, Voice)";
//IVoiceChannel
Task<IAudioClient> IVoiceChannel.ConnectAsync() { throw new NotSupportedException(); }

View File

@@ -22,6 +22,7 @@ namespace Discord.Rest
public override string ToString() => User.ToString();
private string DebuggerDisplay => $"{User}: {Reason}";
//IBan
IUser IBan.User => User;
}
}

View File

@@ -171,6 +171,9 @@ namespace Discord.Rest
public Task<int> PruneUsersAsync(int days = 30, bool simulate = false)
=> GuildHelper.PruneUsersAsync(this, Discord, days, simulate);
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id})";
//IGuild
bool IGuild.Available => Available;
IAudioClient IGuild.AudioClient => null;

View File

@@ -4,7 +4,6 @@ using Model = Discord.API.InviteMetadata;
namespace Discord.Rest
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestInviteMetadata : RestInvite, IInviteMetadata
{
private long _createdAtTicks;

View File

@@ -1,8 +1,9 @@
using Model = Discord.API.Attachment;
using System.Diagnostics;
using Model = Discord.API.Attachment;
namespace Discord
{
//TODO: Rename to Attachment?
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestAttachment : IAttachment
{
public ulong Id { get; }
@@ -29,5 +30,8 @@ namespace Discord
model.Height.IsSpecified ? model.Height.Value : (int?)null,
model.Width.IsSpecified ? model.Width.Value : (int?)null);
}
public override string ToString() => Filename;
private string DebuggerDisplay => $"{Filename} ({Size} bytes)";
}
}

View File

@@ -1,7 +1,9 @@
using Model = Discord.API.Embed;
using System.Diagnostics;
using Model = Discord.API.Embed;
namespace Discord
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestEmbed : IEmbed
{
public string Description { get; }
@@ -26,5 +28,8 @@ namespace Discord
model.Provider.IsSpecified ? EmbedProvider.Create(model.Provider.Value) : (EmbedProvider?)null,
model.Thumbnail.IsSpecified ? EmbedThumbnail.Create(model.Thumbnail.Value) : (EmbedThumbnail?)null);
}
public override string ToString() => Title;
private string DebuggerDisplay => $"{Title} ({Type})";
}
}

View File

@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Threading.Tasks;
using Model = Discord.API.Message;
namespace Discord.Rest
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public abstract class RestMessage : RestEntity<ulong>, IMessage, IUpdateable
{
private long _timestampTicks;
@@ -56,6 +54,8 @@ namespace Discord.Rest
Update(model);
}
public override string ToString() => Content;
MessageType IMessage.Type => MessageType.Default;
}
}

View File

@@ -24,5 +24,7 @@ namespace Discord.Rest
Type = model.Type;
}
private string DebuggerDisplay => $"{Author}: {Content} ({Id}, {Type})";
}
}

View File

@@ -130,5 +130,7 @@ namespace Discord.Rest
text = MentionsHelper.ResolveEveryoneMentions(text, everyoneHandling);
return text;
}
private string DebuggerDisplay => $"{Author}: {Content} ({Id}{(Attachments.Count > 0 ? $", {Attachments.Count} Attachments" : "")}";
}
}

View File

@@ -1,9 +1,11 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Model = Discord.API.Application;
namespace Discord.Rest
{
[DebuggerDisplay(@"{DebuggerDisplay,nq}")]
public class RestApplication : RestEntity<ulong>, IApplication
{
protected string _iconId;
@@ -27,7 +29,6 @@ namespace Discord.Rest
entity.Update(model);
return entity;
}
internal void Update(Model model)
{
Description = model.Description;
@@ -45,5 +46,8 @@ namespace Discord.Rest
throw new InvalidOperationException("Unable to update this object from a different application token.");
Update(response);
}
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id})";
}
}

View File

@@ -46,6 +46,9 @@ namespace Discord.Rest
public Task DeleteAsync()
=> RoleHelper.DeleteAsync(this, Discord);
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id})";
//IRole
IGuild IRole.Guild => Guild;
}

View File

@@ -30,6 +30,6 @@ namespace Discord
}
public override string ToString() => Name;
private string DebuggerDisplay => $"{Name} ({Id}, Type = {Type}{(IsRevoked ? ", Revoked" : "")})";
private string DebuggerDisplay => $"{Name} ({Id}, {Type}{(IsRevoked ? ", Revoked" : "")})";
}
}

View File

@@ -46,6 +46,10 @@ namespace Discord.Rest
public Task<RestDMChannel> CreateDMChannelAsync()
=> UserHelper.CreateDMChannelAsync(this, Discord);
public override string ToString() => $"{Username}#{Discriminator}";
internal string DebuggerDisplay => $"{Username}#{Discriminator} (Id{(IsBot ? ", Bot" : "")})";
//IUser
Task<IDMChannel> IUser.GetDMChannelAsync(CacheMode mode)
=> Task.FromResult<IDMChannel>(null);
async Task<IDMChannel> IUser.CreateDMChannelAsync()