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

@@ -4,7 +4,7 @@
<AssemblyName>Discord.Net.WebSocket</AssemblyName>
<RootNamespace>Discord.WebSocket</RootNamespace>
<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>
</PropertyGroup>
<ItemGroup>

View File

@@ -12,7 +12,7 @@ namespace Discord.WebSocket
/// <summary> Sends a message to this message channel. </summary>
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>
new Task<RestUserMessage> SendFileAsync(string filePath, string text = null, bool isTTS = false, RequestOptions options = null);
#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)
=> 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)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif
@@ -132,7 +132,7 @@ namespace Discord.WebSocket
=> SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options);
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3
#if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#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)
=> 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)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif
@@ -196,7 +196,7 @@ namespace Discord.WebSocket
=> SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options);
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3
#if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#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)
=> 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)
=> ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, options);
#endif
@@ -132,7 +132,7 @@ namespace Discord.WebSocket
=> SocketChannelHelper.GetMessagesAsync(this, Discord, _messages, fromMessage.Id, dir, limit, mode, options);
async Task<IReadOnlyCollection<IMessage>> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options)
=> await GetPinnedMessagesAsync(options).ConfigureAwait(false);
#if NETSTANDARD1_3
#if FILESYSTEM
async Task<IUserMessage> IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, RequestOptions options)
=> await SendFileAsync(filePath, text, isTTS, options).ConfigureAwait(false);
#endif

View File

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

View File

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

View File

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

View File

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