VSCode Formatter - Also bumped tests to net core 3.1

This commit is contained in:
Jonas Dellinger 2020-03-09 20:47:39 +01:00
parent 307d69945e
commit 466e61523d
74 changed files with 2626 additions and 2642 deletions

View File

@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace SpotifyAPI.Web.Auth

View File

@ -18,13 +18,10 @@ namespace SpotifyAPI.Web.Auth
public ProxyConfig ProxyConfig { get; set; }
public AuthorizationCodeAuth(string redirectUri, string serverUri, Scope scope = Scope.None, string state = "")
: base("code", "AuthorizationCodeAuth", redirectUri, serverUri, scope, state)
{
}
public AuthorizationCodeAuth(string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") : base("code", "AuthorizationCodeAuth", redirectUri, serverUri, scope, state)
{ }
public AuthorizationCodeAuth(string clientId, string secretId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "")
: this(redirectUri, serverUri, scope, state)
public AuthorizationCodeAuth(string clientId, string secretId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") : this(redirectUri, serverUri, scope, state)
{
ClientId = clientId;
SecretId = secretId;
@ -130,7 +127,6 @@ namespace SpotifyAPI.Web.Auth
}
public AuthorizationCodeAuthController(IHttpContext context) : base(context)
{
}
{ }
}
}

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
@ -27,8 +27,7 @@ namespace SpotifyAPI.Web.Auth
string auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(ClientId + ":" + ClientSecret));
List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("grant_type", "client_credentials")
{new KeyValuePair<string, string>("grant_type", "client_credentials")
};
HttpClientHandler handler = ProxyConfig.CreateClientHandler(ProxyConfig);

View File

@ -9,8 +9,7 @@ namespace SpotifyAPI.Web.Auth
{
public class ImplicitGrantAuth : SpotifyAuthServer<Token>
{
public ImplicitGrantAuth(string clientId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") :
base("token", "ImplicitGrantAuth", redirectUri, serverUri, scope, state)
public ImplicitGrantAuth(string clientId, string redirectUri, string serverUri, Scope scope = Scope.None, string state = "") : base("token", "ImplicitGrantAuth", redirectUri, serverUri, scope, state)
{
ClientId = clientId;
}
@ -59,7 +58,6 @@ namespace SpotifyAPI.Web.Auth
}
public ImplicitGrantAuthController(IHttpContext context) : base(context)
{
}
{ }
}
}

View File

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

View File

@ -1,14 +1,14 @@
using System;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
using Unosquare.Labs.EmbedIO;
using Unosquare.Labs.EmbedIO.Constants;
using Unosquare.Labs.EmbedIO.Modules;
using SpotifyAPI.Web.Models;
using Newtonsoft.Json;
using System.Net.Http;
namespace SpotifyAPI.Web.Auth
{
@ -91,8 +91,7 @@ namespace SpotifyAPI.Web.Auth
int currentRetries = 0)
{
FormUrlEncodedContent content = new FormUrlEncodedContent(new Dictionary<string, string>
{
{"grant_type", grantType},
{ { "grant_type", grantType },
{ "code", authorizationCode },
{ "refresh_token", refreshToken }
});
@ -111,8 +110,7 @@ namespace SpotifyAPI.Web.Auth
}
}
catch
{
}
{ }
if (currentRetries >= MaxGetTokenRetries)
{
@ -194,8 +192,7 @@ namespace SpotifyAPI.Web.Auth
internal class TokenSwapAuthController : WebApiController
{
public TokenSwapAuthController(IHttpContext context) : base(context)
{
}
{ }
[WebApiHandler(HttpVerbs.Get, "/auth")]
public Task<bool> GetAuth()

View File

@ -1,9 +1,9 @@
using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using SpotifyAPI.Web.Enums;
using SpotifyAPI.Web.Models;
namespace SpotifyAPI.Web.Auth
{
@ -127,8 +127,7 @@ namespace SpotifyAPI.Web.Auth
public static new AccessTokenExpiredEventArgs Empty { get; } = new AccessTokenExpiredEventArgs();
public AccessTokenExpiredEventArgs()
{
}
{ }
}
/// <summary>
/// When the authorization from Spotify expires. This will only occur if <see cref="AutoRefresh"/> is true.
@ -140,8 +139,7 @@ namespace SpotifyAPI.Web.Auth
public static new AuthSuccessEventArgs Empty { get; } = new AuthSuccessEventArgs();
public AuthSuccessEventArgs()
{
}
{ }
}
/// <summary>
/// When an authorization attempt succeeds and gains authorization.

View File

@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization;

View File

@ -26,7 +26,7 @@ namespace SpotifyAPI.Web.Examples.ASP
.AddCookie()
.AddSpotify(options =>
{
var scopes = Scope.UserLibraryRead;
var scopes = Scope.UserLibraryRead | Scope.UserModifyPlaybackState;
options.Scope.Add(scopes.GetStringAttribute(","));
options.SaveTokens = true;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using SpotifyAPI.Web.Auth;
using SpotifyAPI.Web.Enums;
@ -14,13 +14,13 @@ namespace SpotifyAPI.Web.Examples.CLI
// ReSharper disable once UnusedParameter.Local
public static void Main(string[] args)
{
_clientId = string.IsNullOrEmpty(_clientId)
? Environment.GetEnvironmentVariable("SPOTIFY_CLIENT_ID")
: _clientId;
_clientId = string.IsNullOrEmpty(_clientId) ?
Environment.GetEnvironmentVariable("SPOTIFY_CLIENT_ID") :
_clientId;
_secretId = string.IsNullOrEmpty(_secretId)
? Environment.GetEnvironmentVariable("SPOTIFY_SECRET_ID")
: _secretId;
_secretId = string.IsNullOrEmpty(_secretId) ?
Environment.GetEnvironmentVariable("SPOTIFY_SECRET_ID") :
_secretId;
Console.WriteLine("####### Spotify API Example #######");
Console.WriteLine("This example uses AuthorizationCodeAuth.");
@ -37,8 +37,6 @@ namespace SpotifyAPI.Web.Examples.CLI
Console.ReadLine();
auth.Stop(0);
}
private static async void AuthOnAuthReceived(object sender, AuthorizationCode payload)

View File

@ -1,4 +1,4 @@
using System;
using System;
using NUnit.Framework;
namespace SpotifyAPI.Web.Tests

View File

@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -67,7 +67,6 @@ namespace SpotifyAPI.Web.Tests
_mock.Setup(client => client.DownloadJson<PublicProfile>(It.IsAny<string>(), It.IsAny<Dictionary<string, string>>()))
.Returns(new Tuple<ResponseInfo, PublicProfile>(ResponseInfo.Empty, profile));
_spotify.UseAuth = false;
Assert.AreEqual(profile, _spotify.GetPublicProfile("wizzler"));
_mock.Verify(client => client.DownloadJson<PublicProfile>(

View File

@ -1,4 +1,4 @@
using System;
using System;
using NUnit.Framework;
namespace SpotifyAPI.Web.Tests

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace SpotifyAPI.Web.Enums
{

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace SpotifyAPI.Web.Enums
{

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace SpotifyAPI.Web.Enums
{

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace SpotifyAPI.Web.Enums
{

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace SpotifyAPI.Web.Enums
{

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace SpotifyAPI.Web.Enums
{

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace SpotifyAPI.Web.Enums
{

View File

@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SpotifyAPI.Web.Models;
namespace SpotifyAPI.Web

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Net;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{
@ -18,8 +18,7 @@ namespace SpotifyAPI.Web.Models
}
public class ErrorResponse : BasicModel
{
}
{ }
public class Error
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using System;
using System;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SpotifyAPI.Web.Enums;

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models

View File

@ -1,4 +1,4 @@
using System.Net;
using System.Net;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System;
using Newtonsoft.Json;
namespace SpotifyAPI.Web.Models
{

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
@ -57,9 +57,9 @@ namespace SpotifyAPI.Web.Models
string name = info.GetCustomAttribute<StringAttribute>()?.Text;
if (name == null || value == null)
continue;
urlParams.Add(value is float valueAsFloat
? $"{prefix}_{name}={valueAsFloat.ToString(CultureInfo.InvariantCulture)}"
: $"{prefix}_{name}={value}");
urlParams.Add(value is float valueAsFloat ?
$"{prefix}_{name}={valueAsFloat.ToString(CultureInfo.InvariantCulture)}" :
$"{prefix}_{name}={value}");
}
if (urlParams.Count > 0)
return "&" + string.Join("&", urlParams);

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Net;
using System.Net.Http;

View File

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

View File

@ -1,4 +1,3 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net;
@ -6,6 +5,7 @@ using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using SpotifyAPI.Web.Models;
namespace SpotifyAPI.Web
@ -83,7 +83,8 @@ namespace SpotifyAPI.Web
public async Task<Tuple<ResponseInfo, T>> DownloadJsonAsync<T>(string url, Dictionary<string, string> headers = null)
{
Tuple<ResponseInfo, string> response = await DownloadAsync(url, headers).ConfigureAwait(false);try
Tuple<ResponseInfo, string> response = await DownloadAsync(url, headers).ConfigureAwait(false);
try
{
return new Tuple<ResponseInfo, T>(response.Item1, JsonConvert.DeserializeObject<T>(response.Item2, JsonSettings));
}

View File

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