Added net45 TFM

This commit is contained in:
RogueException
2017-04-26 10:25:08 -03:00
parent f8b9acc4a1
commit a306d83283
33 changed files with 82 additions and 57 deletions

View File

@@ -17,6 +17,12 @@
<VersionSuffix Condition=" '$(VersionSuffix)' == '' ">$(BuildNumber)</VersionSuffix> <VersionSuffix Condition=" '$(VersionSuffix)' == '' ">$(BuildNumber)</VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix> <VersionSuffix Condition=" '$(VersionSuffix)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' Or '$(TargetFramework)' == 'net45' ">
<DefineConstants>$(DefineConstants);FILESYSTEM;DEFAULTUDPCLIENT;DEFAULTWEBSOCKET</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>$(DefineConstants);FORMATSTR;UNIXTIME;MSTRYBUFFER;UDPDISPOSE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<NoWarn>$(NoWarn);CS1573;CS1591</NoWarn> <NoWarn>$(NoWarn);CS1573;CS1591</NoWarn>
<WarningsAsErrors>true</WarningsAsErrors> <WarningsAsErrors>true</WarningsAsErrors>

View File

@@ -4,7 +4,7 @@
<AssemblyName>Discord.Net.Core</AssemblyName> <AssemblyName>Discord.Net.Core</AssemblyName>
<RootNamespace>Discord</RootNamespace> <RootNamespace>Discord</RootNamespace>
<Description>The core components for the Discord.Net library.</Description> <Description>The core components for the Discord.Net library.</Description>
<TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks> <TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />

View File

@@ -9,7 +9,7 @@ namespace Discord
{ {
/// <summary> Sends a message to this message channel. </summary> /// <summary> Sends a message to this message channel. </summary>
Task<IUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null); Task<IUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null);
#if NETSTANDARD1_3 #if FILESYSTEM
/// <summary> Sends a file to this text channel, with an optional caption. </summary> /// <summary> Sends a file to this text channel, with an optional caption. </summary>
Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null); Task<IUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
#endif #endif

View File

@@ -15,7 +15,7 @@ namespace Discord
{ {
Stream = stream; Stream = stream;
} }
#if NETSTANDARD1_3 #if FILESYSTEM
/// <summary> /// <summary>
/// Create the image from a file path. /// Create the image from a file path.
/// </summary> /// </summary>

View File

@@ -35,7 +35,7 @@ namespace Discord.Logging
} }
catch { } catch { }
} }
#if NETSTANDARD1_3 #if FORMATSTR
public async Task LogAsync(LogSeverity severity, string source, FormattableString message, Exception ex = null) public async Task LogAsync(LogSeverity severity, string source, FormattableString message, Exception ex = null)
{ {
try try
@@ -51,7 +51,7 @@ namespace Discord.Logging
=> LogAsync(LogSeverity.Error, source, ex); => LogAsync(LogSeverity.Error, source, ex);
public Task ErrorAsync(string source, string message, Exception ex = null) public Task ErrorAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Error, source, message, ex); => LogAsync(LogSeverity.Error, source, message, ex);
#if NETSTANDARD1_3 #if FORMATSTR
public Task ErrorAsync(string source, FormattableString message, Exception ex = null) public Task ErrorAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Error, source, message, ex); => LogAsync(LogSeverity.Error, source, message, ex);
#endif #endif
@@ -60,7 +60,7 @@ namespace Discord.Logging
=> LogAsync(LogSeverity.Warning, source, ex); => LogAsync(LogSeverity.Warning, source, ex);
public Task WarningAsync(string source, string message, Exception ex = null) public Task WarningAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Warning, source, message, ex); => LogAsync(LogSeverity.Warning, source, message, ex);
#if NETSTANDARD1_3 #if FORMATSTR
public Task WarningAsync(string source, FormattableString message, Exception ex = null) public Task WarningAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Warning, source, message, ex); => LogAsync(LogSeverity.Warning, source, message, ex);
#endif #endif
@@ -69,7 +69,7 @@ namespace Discord.Logging
=> LogAsync(LogSeverity.Info, source, ex); => LogAsync(LogSeverity.Info, source, ex);
public Task InfoAsync(string source, string message, Exception ex = null) public Task InfoAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Info, source, message, ex); => LogAsync(LogSeverity.Info, source, message, ex);
#if NETSTANDARD1_3 #if FORMATSTR
public Task InfoAsync(string source, FormattableString message, Exception ex = null) public Task InfoAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Info, source, message, ex); => LogAsync(LogSeverity.Info, source, message, ex);
#endif #endif
@@ -78,7 +78,7 @@ namespace Discord.Logging
=> LogAsync(LogSeverity.Verbose, source, ex); => LogAsync(LogSeverity.Verbose, source, ex);
public Task VerboseAsync(string source, string message, Exception ex = null) public Task VerboseAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Verbose, source, message, ex); => LogAsync(LogSeverity.Verbose, source, message, ex);
#if NETSTANDARD1_3 #if FORMATSTR
public Task VerboseAsync(string source, FormattableString message, Exception ex = null) public Task VerboseAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Verbose, source, message, ex); => LogAsync(LogSeverity.Verbose, source, message, ex);
#endif #endif
@@ -87,7 +87,7 @@ namespace Discord.Logging
=> LogAsync(LogSeverity.Debug, source, ex); => LogAsync(LogSeverity.Debug, source, ex);
public Task DebugAsync(string source, string message, Exception ex = null) public Task DebugAsync(string source, string message, Exception ex = null)
=> LogAsync(LogSeverity.Debug, source, message, ex); => LogAsync(LogSeverity.Debug, source, message, ex);
#if NETSTANDARD1_3 #if FORMATSTR
public Task DebugAsync(string source, FormattableString message, Exception ex = null) public Task DebugAsync(string source, FormattableString message, Exception ex = null)
=> LogAsync(LogSeverity.Debug, source, message, ex); => LogAsync(LogSeverity.Debug, source, message, ex);
#endif #endif

View File

@@ -20,7 +20,7 @@ namespace Discord.Logging
=> _manager.LogAsync(severity, Name, exception); => _manager.LogAsync(severity, Name, exception);
public Task LogAsync(LogSeverity severity, string message, Exception exception = null) public Task LogAsync(LogSeverity severity, string message, Exception exception = null)
=> _manager.LogAsync(severity, Name, message, exception); => _manager.LogAsync(severity, Name, message, exception);
#if NETSTANDARD1_3 #if FORMATSTR
public Task LogAsync(LogSeverity severity, FormattableString message, Exception exception = null) public Task LogAsync(LogSeverity severity, FormattableString message, Exception exception = null)
=> _manager.LogAsync(severity, Name, message, exception); => _manager.LogAsync(severity, Name, message, exception);
#endif #endif
@@ -29,7 +29,7 @@ namespace Discord.Logging
=> _manager.ErrorAsync(Name, exception); => _manager.ErrorAsync(Name, exception);
public Task ErrorAsync(string message, Exception exception = null) public Task ErrorAsync(string message, Exception exception = null)
=> _manager.ErrorAsync(Name, message, exception); => _manager.ErrorAsync(Name, message, exception);
#if NETSTANDARD1_3 #if FORMATSTR
public Task ErrorAsync(FormattableString message, Exception exception = null) public Task ErrorAsync(FormattableString message, Exception exception = null)
=> _manager.ErrorAsync(Name, message, exception); => _manager.ErrorAsync(Name, message, exception);
#endif #endif
@@ -38,7 +38,7 @@ namespace Discord.Logging
=> _manager.WarningAsync(Name, exception); => _manager.WarningAsync(Name, exception);
public Task WarningAsync(string message, Exception exception = null) public Task WarningAsync(string message, Exception exception = null)
=> _manager.WarningAsync(Name, message, exception); => _manager.WarningAsync(Name, message, exception);
#if NETSTANDARD1_3 #if FORMATSTR
public Task WarningAsync(FormattableString message, Exception exception = null) public Task WarningAsync(FormattableString message, Exception exception = null)
=> _manager.WarningAsync(Name, message, exception); => _manager.WarningAsync(Name, message, exception);
#endif #endif
@@ -47,7 +47,7 @@ namespace Discord.Logging
=> _manager.InfoAsync(Name, exception); => _manager.InfoAsync(Name, exception);
public Task InfoAsync(string message, Exception exception = null) public Task InfoAsync(string message, Exception exception = null)
=> _manager.InfoAsync(Name, message, exception); => _manager.InfoAsync(Name, message, exception);
#if NETSTANDARD1_3 #if FORMATSTR
public Task InfoAsync(FormattableString message, Exception exception = null) public Task InfoAsync(FormattableString message, Exception exception = null)
=> _manager.InfoAsync(Name, message, exception); => _manager.InfoAsync(Name, message, exception);
#endif #endif
@@ -56,7 +56,7 @@ namespace Discord.Logging
=> _manager.VerboseAsync(Name, exception); => _manager.VerboseAsync(Name, exception);
public Task VerboseAsync(string message, Exception exception = null) public Task VerboseAsync(string message, Exception exception = null)
=> _manager.VerboseAsync(Name, message, exception); => _manager.VerboseAsync(Name, message, exception);
#if NETSTANDARD1_3 #if FORMATSTR
public Task VerboseAsync(FormattableString message, Exception exception = null) public Task VerboseAsync(FormattableString message, Exception exception = null)
=> _manager.VerboseAsync(Name, message, exception); => _manager.VerboseAsync(Name, message, exception);
#endif #endif
@@ -65,7 +65,7 @@ namespace Discord.Logging
=> _manager.DebugAsync(Name, exception); => _manager.DebugAsync(Name, exception);
public Task DebugAsync(string message, Exception exception = null) public Task DebugAsync(string message, Exception exception = null)
=> _manager.DebugAsync(Name, message, exception); => _manager.DebugAsync(Name, message, exception);
#if NETSTANDARD1_3 #if FORMATSTR
public Task DebugAsync(FormattableString message, Exception exception = null) public Task DebugAsync(FormattableString message, Exception exception = null)
=> _manager.DebugAsync(Name, message, exception); => _manager.DebugAsync(Name, message, exception);
#endif #endif

View File

@@ -5,7 +5,7 @@ namespace Discord
//Source: https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/DateTimeOffset.cs //Source: https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/DateTimeOffset.cs
internal static class DateTimeUtils internal static class DateTimeUtils
{ {
#if !NETSTANDARD1_3 #if !UNIXTIME
private const long UnixEpochTicks = 621_355_968_000_000_000; private const long UnixEpochTicks = 621_355_968_000_000_000;
private const long UnixEpochSeconds = 62_135_596_800; private const long UnixEpochSeconds = 62_135_596_800;
private const long UnixEpochMilliseconds = 62_135_596_800_000; private const long UnixEpochMilliseconds = 62_135_596_800_000;
@@ -18,7 +18,7 @@ namespace Discord
public static DateTimeOffset FromUnixSeconds(long seconds) public static DateTimeOffset FromUnixSeconds(long seconds)
{ {
#if NETSTANDARD1_3 #if UNIXTIME
return DateTimeOffset.FromUnixTimeSeconds(seconds); return DateTimeOffset.FromUnixTimeSeconds(seconds);
#else #else
long ticks = seconds * TimeSpan.TicksPerSecond + UnixEpochTicks; long ticks = seconds * TimeSpan.TicksPerSecond + UnixEpochTicks;
@@ -27,7 +27,7 @@ namespace Discord
} }
public static DateTimeOffset FromUnixMilliseconds(long milliseconds) public static DateTimeOffset FromUnixMilliseconds(long milliseconds)
{ {
#if NETSTANDARD1_3 #if UNIXTIME
return DateTimeOffset.FromUnixTimeMilliseconds(milliseconds); return DateTimeOffset.FromUnixTimeMilliseconds(milliseconds);
#else #else
long ticks = milliseconds * TimeSpan.TicksPerMillisecond + UnixEpochTicks; long ticks = milliseconds * TimeSpan.TicksPerMillisecond + UnixEpochTicks;
@@ -37,7 +37,7 @@ namespace Discord
public static long ToUnixSeconds(DateTimeOffset dto) public static long ToUnixSeconds(DateTimeOffset dto)
{ {
#if NETSTANDARD1_3 #if UNIXTIME
return dto.ToUnixTimeSeconds(); return dto.ToUnixTimeSeconds();
#else #else
long seconds = dto.UtcDateTime.Ticks / TimeSpan.TicksPerSecond; long seconds = dto.UtcDateTime.Ticks / TimeSpan.TicksPerSecond;
@@ -46,7 +46,7 @@ namespace Discord
} }
public static long ToUnixMilliseconds(DateTimeOffset dto) public static long ToUnixMilliseconds(DateTimeOffset dto)
{ {
#if NETSTANDARD1_3 #if UNIXTIME
return dto.ToUnixTimeMilliseconds(); return dto.ToUnixTimeMilliseconds();
#else #else
long milliseconds = dto.UtcDateTime.Ticks / TimeSpan.TicksPerMillisecond; long milliseconds = dto.UtcDateTime.Ticks / TimeSpan.TicksPerMillisecond;

View File

@@ -4,7 +4,7 @@
<AssemblyName>Discord.Net.DebugTools</AssemblyName> <AssemblyName>Discord.Net.DebugTools</AssemblyName>
<RootNamespace>Discord</RootNamespace> <RootNamespace>Discord</RootNamespace>
<Description>A Discord.Net extension adding some helper classes for diagnosing issues.</Description> <Description>A Discord.Net extension adding some helper classes for diagnosing issues.</Description>
<TargetFrameworks>netstandard1.6</TargetFrameworks> <TargetFrameworks>net45;netstandard1.3</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" /> <ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />

View File

@@ -213,11 +213,14 @@ namespace Discord.Net.Providers.UnstableWebSocket
//Use the internal buffer if we can get it //Use the internal buffer if we can get it
resultCount = (int)stream.Length; resultCount = (int)stream.Length;
ArraySegment<byte> streamBuffer; #if MSTRYBUFFER
if (stream.TryGetBuffer(out streamBuffer)) if (stream.TryGetBuffer(out var streamBuffer))
result = streamBuffer.Array; result = streamBuffer.Array;
else else
result = stream.ToArray(); result = stream.ToArray();
#else
result = stream.GetBuffer();
#endif
} }
} }
else else

View File

@@ -4,7 +4,7 @@
<AssemblyName>Discord.Net.Rest</AssemblyName> <AssemblyName>Discord.Net.Rest</AssemblyName>
<RootNamespace>Discord.Rest</RootNamespace> <RootNamespace>Discord.Rest</RootNamespace>
<Description>A core Discord.Net library containing the REST client and models.</Description> <Description>A core Discord.Net library containing the REST client and models.</Description>
<TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks> <TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" /> <ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />

View File

@@ -163,7 +163,7 @@ namespace Discord.Rest
return RestUserMessage.Create(client, channel, client.CurrentUser, model); return RestUserMessage.Create(client, channel, client.CurrentUser, model);
} }
#if NETSTANDARD1_3 #if FILESYSTEM
public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client, public static async Task<RestUserMessage> SendFileAsync(IMessageChannel channel, BaseDiscordClient client,
string filePath, string text, bool isTTS, RequestOptions options) string filePath, string text, bool isTTS, RequestOptions options)
{ {

View File

@@ -8,7 +8,7 @@ namespace Discord.Rest
{ {
/// <summary> Sends a message to this message channel. </summary> /// <summary> Sends a message to this message channel. </summary>
new Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null); new Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null);
#if NETSTANDARD1_3 #if FILESYSTEM
/// <summary> Sends a file to this text channel, with an optional caption. </summary> /// <summary> Sends a file to this text channel, with an optional caption. </summary>
new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null); new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
#endif #endif

View File

@@ -65,7 +65,7 @@ namespace Discord.Rest
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -124,7 +124,7 @@ namespace Discord.Rest
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -78,7 +78,7 @@ namespace Discord.Rest
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -134,7 +134,7 @@ namespace Discord.Rest
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -56,7 +56,7 @@ namespace Discord.Rest
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -105,7 +105,7 @@ namespace Discord.Rest
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -35,7 +35,7 @@ namespace Discord.Rest
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -84,7 +84,7 @@ namespace Discord.Rest
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options); => await GetPinnedMessagesAsync(options);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options); => await SendFileAsync(filePath, text, isTTS, options);
#endif #endif

View File

@@ -4,7 +4,7 @@
<AssemblyName>Discord.Net.Rpc</AssemblyName> <AssemblyName>Discord.Net.Rpc</AssemblyName>
<RootNamespace>Discord.Rpc</RootNamespace> <RootNamespace>Discord.Rpc</RootNamespace>
<Description>A core Discord.Net library containing the RPC client and models.</Description> <Description>A core Discord.Net library containing the RPC client and models.</Description>
<TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks> <TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Discord.Net.WebSocket\Net\DefaultWebSocketClient.cs"> <Compile Include="..\Discord.Net.WebSocket\Net\DefaultWebSocketClient.cs">

View File

@@ -19,7 +19,7 @@ namespace Discord.Rpc
public DiscordRpcConfig() public DiscordRpcConfig()
{ {
#if NETSTANDARD1_3 #if FILESYSTEM
WebSocketProvider = () => new DefaultWebSocketClient(); WebSocketProvider = () => new DefaultWebSocketClient();
#else #else
WebSocketProvider = () => WebSocketProvider = () =>

View File

@@ -46,7 +46,7 @@ namespace Discord.Rpc
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -102,7 +102,7 @@ namespace Discord.Rpc
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -49,7 +49,7 @@ namespace Discord.Rpc
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -102,7 +102,7 @@ namespace Discord.Rpc
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -50,7 +50,7 @@ namespace Discord.Rpc
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -102,7 +102,7 @@ namespace Discord.Rpc
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -4,7 +4,7 @@
<AssemblyName>Discord.Net.WebSocket</AssemblyName> <AssemblyName>Discord.Net.WebSocket</AssemblyName>
<RootNamespace>Discord.WebSocket</RootNamespace> <RootNamespace>Discord.WebSocket</RootNamespace>
<Description>A core Discord.Net library containing the WebSocket client and models.</Description> <Description>A core Discord.Net library containing the WebSocket client and models.</Description>
<TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks> <TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -12,7 +12,7 @@ namespace Discord.WebSocket
/// <summary> Sends a message to this message channel. </summary> /// <summary> Sends a message to this message channel. </summary>
new Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null); new Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null);
#if NETSTANDARD1_3 #if FILESYSTEM
/// <summary> Sends a file to this text channel, with an optional caption. </summary> /// <summary> Sends a file to this text channel, with an optional caption. </summary>
new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null); new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
#endif #endif

View File

@@ -68,7 +68,7 @@ namespace Discord.WebSocket
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -132,7 +132,7 @@ namespace Discord.WebSocket
=> SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options);
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -97,7 +97,7 @@ namespace Discord.WebSocket
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -196,7 +196,7 @@ namespace Discord.WebSocket
=> SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options);
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -73,7 +73,7 @@ namespace Discord.WebSocket
public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null) public Task<RestUserMessage> SendMessageAsync(string text, bool isTTS = false, Embed embed = null, RequestOptions options = null)
=> ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options); => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, options);
#if NETSTANDARD1_3 #if FILESYSTEM
public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null) public Task<RestUserMessage> SendFileAsync(string filePath, string text, bool isTTS = false, RequestOptions options = null)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options); => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif #endif
@@ -132,7 +132,7 @@ namespace Discord.WebSocket
=> SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options); => SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options);
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false); => await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3 #if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options) async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false); => await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif #endif

View File

@@ -1,4 +1,4 @@
#if NETSTANDARD1_3 #if DEFAULTUDPCLIENT
using System; using System;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
@@ -85,7 +85,11 @@ namespace Discord.Net.Udp
if (_udp != null) if (_udp != null)
{ {
#if UDPDISPOSE
try { _udp.Dispose(); } try { _udp.Dispose(); }
#else
try { _udp.Close(); }
#endif
catch { } catch { }
_udp = null; _udp = null;
} }

View File

@@ -4,7 +4,7 @@ namespace Discord.Net.Udp
{ {
public static class DefaultUdpSocketProvider public static class DefaultUdpSocketProvider
{ {
#if NETSTANDARD1_3 #if DEFAULTUDPCLIENT
public static readonly UdpSocketProvider Instance = () => public static readonly UdpSocketProvider Instance = () =>
{ {
try try

View File

@@ -1,4 +1,4 @@
#if NETSTANDARD1_3 #if DEFAULTWEBSOCKET
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@@ -206,10 +206,14 @@ namespace Discord.Net.WebSockets
//Use the internal buffer if we can get it //Use the internal buffer if we can get it
resultCount = (int)stream.Length; resultCount = (int)stream.Length;
if (stream.TryGetBuffer(out ArraySegment<byte> streamBuffer)) #if MSTRYBUFFER
if (stream.TryGetBuffer(out var streamBuffer))
result = streamBuffer.Array; result = streamBuffer.Array;
else else
result = stream.ToArray(); result = stream.ToArray();
#else
result = stream.GetBuffer();
#endif
} }
} }
else else

View File

@@ -4,7 +4,7 @@ namespace Discord.Net.WebSockets
{ {
public static class DefaultWebSocketProvider public static class DefaultWebSocketProvider
{ {
#if NETSTANDARD1_3 #if DEFAULTWEBSOCKET
public static readonly WebSocketProvider Instance = () => public static readonly WebSocketProvider Instance = () =>
{ {
try try

View File

@@ -4,7 +4,7 @@
<AssemblyName>Discord.Net.Webhook</AssemblyName> <AssemblyName>Discord.Net.Webhook</AssemblyName>
<RootNamespace>Discord.Webhook</RootNamespace> <RootNamespace>Discord.Webhook</RootNamespace>
<Description>A core Discord.Net library containing the Webhook client and models.</Description> <Description>A core Discord.Net library containing the Webhook client and models.</Description>
<TargetFrameworks>netstandard1.1;netstandard1.3</TargetFrameworks> <TargetFrameworks>netstandard1.1</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" /> <ProjectReference Include="..\Discord.Net.Core\Discord.Net.Core.csproj" />

View File

@@ -59,7 +59,7 @@ namespace Discord.Webhook
await ApiClient.CreateWebhookMessageAsync(_webhookId, args, options).ConfigureAwait(false); await ApiClient.CreateWebhookMessageAsync(_webhookId, args, options).ConfigureAwait(false);
} }
#if NETSTANDARD1_3 #if FILESYSTEM
public async Task SendFileAsync(string filePath, string text, bool isTTS = false, public async Task SendFileAsync(string filePath, string text, bool isTTS = false,
string username = null, string avatarUrl = null, RequestOptions options = null) string username = null, string avatarUrl = null, RequestOptions options = null)
{ {

View File

@@ -12,6 +12,14 @@
<licenseUrl>http://opensource.org/licenses/MIT</licenseUrl> <licenseUrl>http://opensource.org/licenses/MIT</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance> <requireLicenseAcceptance>false</requireLicenseAcceptance>
<dependencies> <dependencies>
<group targetFramework="net45">
<dependency id="Discord.Net.Core" version="1.0.0-rc2$suffix$" />
<dependency id="Discord.Net.Rest" version="1.0.0-rc2$suffix$" />
<dependency id="Discord.Net.WebSocket" version="1.0.0-rc2$suffix$" />
<dependency id="Discord.Net.Rpc" version="1.0.0-rc2$suffix$" />
<dependency id="Discord.Net.Commands" version="1.0.0-rc2$suffix$" />
<dependency id="Discord.Net.Webhook" version="1.0.0-rc2$suffix$" />
</group>
<group targetFramework="netstandard1.1"> <group targetFramework="netstandard1.1">
<dependency id="Discord.Net.Core" version="1.0.0-rc2$suffix$" /> <dependency id="Discord.Net.Core" version="1.0.0-rc2$suffix$" />
<dependency id="Discord.Net.Rest" version="1.0.0-rc2$suffix$" /> <dependency id="Discord.Net.Rest" version="1.0.0-rc2$suffix$" />