mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-18 09:35:38 -05:00
Add linting for copyright and unused usings (#1416)
* Add linting for copyright and unused usings * Add one more + comment * Enforce in build and fix errors * Fix build
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -17,7 +18,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Implementation for <see cref="IAzureAuthenticationManager" />.
|
||||
/// Implementation for <see cref="IAzureAuthenticationManager" />.
|
||||
/// Provides functionality to authenticate to Azure and discover associated accounts and subscriptions
|
||||
/// </summary>
|
||||
[Exportable(
|
||||
@@ -79,7 +80,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
OnCurrentAccountChanged();
|
||||
return await GetCurrentAccountAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Public for testing purposes. Creates an Azure account with the correct set of mappings for tenants etc.
|
||||
/// </summary>
|
||||
@@ -185,7 +186,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
return _selectedSubscriptions ?? await GetSubscriptionsAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns user's subscriptions
|
||||
/// </summary>
|
||||
@@ -219,7 +220,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
private async Task<IEnumerable<IAzureUserAccountSubscriptionContext>> GetSubscriptionsFromCacheAsync(AzureUserAccount user)
|
||||
{
|
||||
var result = Enumerable.Empty<IAzureUserAccountSubscriptionContext>();
|
||||
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
if (user.UniqueId != "") {
|
||||
@@ -278,7 +279,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
? subscriptionList
|
||||
: subscriptionList.Where(x => subscriptionIds.Contains(x.Subscription.SubscriptionId)).ToList();
|
||||
|
||||
//If the current account changes during setting selected subscription, none of the ids should be found
|
||||
//If the current account changes during setting selected subscription, none of the ids should be found
|
||||
//so we just reset the selected subscriptions
|
||||
if (subscriptionIds != null && subscriptionIds.Any() && newSelectedSubscriptions.Count == 0)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
@@ -35,7 +36,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception. </param>
|
||||
/// <param name="httpStatusCode">The Http error code. </param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
|
||||
/// (Nothing in Visual Basic) if no inner exception is specified</param>
|
||||
public AzureResourceFailedException(string message, HttpStatusCode httpStatusCode, Exception innerException = null)
|
||||
: base(message, httpStatusCode, innerException)
|
||||
@@ -47,20 +48,20 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception. </param>
|
||||
/// <param name="httpStatusCode">The Http error code. </param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
|
||||
/// (Nothing in Visual Basic) if no inner exception is specified</param>
|
||||
public AzureResourceFailedException(string message, int httpStatusCode, Exception innerException = null)
|
||||
: base(message, httpStatusCode, innerException)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AuthenticationFailedException class with a specified error message
|
||||
/// Initializes a new instance of the AuthenticationFailedException class with a specified error message
|
||||
/// and a reference to the inner exception that is the cause of this exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception. </param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
|
||||
/// (Nothing in Visual Basic) if no inner exception is specified</param>
|
||||
public AzureResourceFailedException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.Azure.Management.ResourceManager;
|
||||
@@ -11,7 +12,7 @@ using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
|
||||
namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
/// <summary>
|
||||
/// VS session used by <see cref="AzureResourceManager" />.
|
||||
/// VS session used by <see cref="AzureResourceManager" />.
|
||||
/// Includes all the clients that the resource management needs to get ther resources
|
||||
/// </summary>
|
||||
public class AzureResourceManagementSession : IAzureResourceManagementSession
|
||||
@@ -22,7 +23,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
/// <param name="sqlManagementClient">Sql Management Client</param>
|
||||
/// <param name="resourceManagementClient">Resource Management Client</param>
|
||||
/// <param name="subscriptionContext">Subscription Context</param>
|
||||
public AzureResourceManagementSession(SqlManagementClient sqlManagementClient,
|
||||
public AzureResourceManagementSession(SqlManagementClient sqlManagementClient,
|
||||
ResourceManagementClient resourceManagementClient,
|
||||
IAzureUserAccountSubscriptionContext subscriptionContext)
|
||||
{
|
||||
@@ -46,7 +47,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
public bool CloseSession()
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
if (ResourceManagementClient != null)
|
||||
{
|
||||
ResourceManagementClient.Dispose();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -43,7 +44,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
public AzureResourceManager()
|
||||
{
|
||||
// Duplicate the exportable attribute as at present we do not support filtering using extensiondescriptor.
|
||||
// The attribute is preserved in order to simplify ability to backport into existing tools
|
||||
// The attribute is preserved in order to simplify ability to backport into existing tools
|
||||
Metadata = new ExportableMetadata(
|
||||
ServerTypes.SqlServer,
|
||||
Categories.Azure,
|
||||
@@ -222,7 +223,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all subscription contexts under a specific user account. Queries all tenants for the account and uses these to log in
|
||||
/// Gets all subscription contexts under a specific user account. Queries all tenants for the account and uses these to log in
|
||||
/// and retrieve subscription information as needed
|
||||
/// </summary>
|
||||
public async Task<IEnumerable<IAzureUserAccountSubscriptionContext>> GetSubscriptionContextsAsync(IAzureUserAccount userAccount)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.Azure.Management.Sql.Models;
|
||||
@@ -9,7 +10,7 @@ using Microsoft.SqlTools.ResourceProvider.Core;
|
||||
namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation for <see cref="IAzureResource" /> using VS services.
|
||||
/// Implementation for <see cref="IAzureResource" /> using VS services.
|
||||
/// Provides information about an Azure resource
|
||||
/// </summary>
|
||||
public class AzureResourceWrapper : IAzureResource
|
||||
@@ -18,7 +19,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
private string resourceGroupName;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the resource
|
||||
/// Initializes the resource
|
||||
/// </summary>
|
||||
public AzureResourceWrapper(TrackedResource azureResource)
|
||||
{
|
||||
@@ -94,7 +95,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
if (!string.IsNullOrEmpty(Id))
|
||||
{
|
||||
string[] idParts = Id.Split('/');
|
||||
|
||||
|
||||
// Look for the "resourceGroups" section and return the section after this, hence
|
||||
// always stop before idParts.Length - 1
|
||||
for (int i = 0; i < idParts.Length - 1; i++)
|
||||
@@ -134,5 +135,5 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
|
||||
|
||||
@@ -48,7 +49,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
{
|
||||
get
|
||||
{
|
||||
return _azureSubscriptionIdentifier != null ?
|
||||
return _azureSubscriptionIdentifier != null ?
|
||||
_azureSubscriptionIdentifier.SubscriptionId : string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core;
|
||||
@@ -31,7 +32,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
public bool Equals(IAzureSubscriptionIdentifier other)
|
||||
{
|
||||
return other != null &&
|
||||
CommonUtil.SameString(SubscriptionId, other.SubscriptionId) &&
|
||||
CommonUtil.SameString(SubscriptionId, other.SubscriptionId) &&
|
||||
CommonUtil.SameUri(ServiceManagementEndpoint, other.ServiceManagementEndpoint);
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the tenant this subscription comes from
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -27,7 +28,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// URI defining the root for resource lookup
|
||||
/// </summary>
|
||||
@@ -35,7 +36,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Access token for use in login scenarios. Note that we could consider implementing this better in the
|
||||
/// Access token for use in login scenarios. Note that we could consider implementing this better in the
|
||||
/// </summary>
|
||||
public string AccessToken
|
||||
{
|
||||
@@ -44,7 +45,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optional token type defining whether this is a Bearer token or other type of token
|
||||
/// Optional token type defining whether this is a Bearer token or other type of token
|
||||
/// </summary>
|
||||
public string TokenType
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -53,7 +54,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
CommonUtil.SameString(other.TenantId, TenantId);
|
||||
// TODO probably should check the AllTenants field
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unique Id
|
||||
/// </summary>
|
||||
@@ -68,7 +69,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
this.uniqueId = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if user needs reauthentication
|
||||
/// </summary>
|
||||
@@ -77,7 +78,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// User display info
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
|
||||
|
||||
@@ -45,8 +46,8 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
/// </summary>
|
||||
public bool Equals(IAzureUserAccountDisplayInfo other)
|
||||
{
|
||||
return other != null &&
|
||||
((other.AccountDisplayName == null && AccountDisplayName == null ) || (other.AccountDisplayName != null && other.AccountDisplayName.Equals(AccountDisplayName))) &&
|
||||
return other != null &&
|
||||
((other.AccountDisplayName == null && AccountDisplayName == null ) || (other.AccountDisplayName != null && other.AccountDisplayName.Equals(AccountDisplayName))) &&
|
||||
((other.UserName == null && UserName == null ) || (other.UserName != null && other.UserName.Equals(UserName)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.Rest;
|
||||
@@ -28,7 +29,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a subscription context for connecting with a known access token. This creates a <see cref="TokenCredentials"/> object for use
|
||||
/// Creates a subscription context for connecting with a known access token. This creates a <see cref="TokenCredentials"/> object for use
|
||||
/// in a request
|
||||
/// </summary>
|
||||
public static AzureUserAccountSubscriptionContext CreateStringTokenContext(AzureSubscriptionIdentifier subscription, string accessToken)
|
||||
@@ -62,7 +63,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public bool Equals(IAzureUserAccountSubscriptionContext other)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.SqlTools.ResourceProvider.Core;
|
||||
@@ -17,7 +18,7 @@ namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
|
||||
private readonly Models.Server _azureSqlServerResource;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the resource
|
||||
/// Initializes the resource
|
||||
/// </summary>
|
||||
public SqlAzureResource(Models.Server azureResource) : base(azureResource)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user