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:
Charles Gagnon
2022-03-04 15:17:29 -08:00
committed by GitHub
parent 025f9af4fd
commit c248400a6c
233 changed files with 1323 additions and 364 deletions

View File

@@ -10,7 +10,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
{
/// <summary>
/// Attribute defining a service export, and the metadata about that service. Implements IServiceMetadata,
/// which should be used on the importer side to ensure type consistency. Services and providers have to add this property
/// which should be used on the importer side to ensure type consistency. Services and providers have to add this property
/// in order to be found by the extension manager
/// </summary>
[MetadataAttribute]
@@ -27,11 +27,11 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// <param name="priority">The priority of the exportable. The extension manager will pick the exportable with the highest priority if multiple found</param>
/// <param name="displayName">The display name of the exportable. This field is optional</param>
public ExportableAttribute(
string serverType,
string serverType,
string category,
Type type,
string id,
int priority = 0,
Type type,
string id,
int priority = 0,
string displayName = null) : base(type)
{
Category = category;
@@ -40,7 +40,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
DisplayName = displayName;
Priority = priority;
}
/// <summary>
/// The constructor to define an exportable by type, id and priority only. To be used by the exportables that support all server types and categories.
/// For example: the implementation of <see cref="ITrace" /> can be used for all server types and categories.
@@ -60,8 +60,8 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// </summary>
public string Category
{
get;
private set;
get;
private set;
}
/// <summary>
@@ -69,8 +69,8 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// </summary>
public string ServerType
{
get;
private set;
get;
private set;
}
/// <summary>
@@ -87,7 +87,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// </summary>
public string Id
{
get;
get;
private set;
}
@@ -96,7 +96,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// </summary>
public string DisplayName
{
get;
get;
private set;
}
@@ -105,7 +105,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// </summary>
public int Priority
{
get;
get;
private set;
}
}

View File

@@ -26,7 +26,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// </summary>
public IExportableMetadata Metadata
{
get;
get;
set;
}
@@ -36,7 +36,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// </summary>
public IMultiServiceProvider ServiceProvider
{
get;
get;
private set;
}
@@ -53,7 +53,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// <returns>A service of type T or null if not found</returns>
protected T GetService<T>()
where T : IExportable
{
{
return GetService<T>(Metadata);
}
@@ -90,7 +90,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
}
/// <summary>
/// ServerDefinition created from the metadata
/// ServerDefinition created from the metadata
/// </summary>
protected ServerDefinition ServerDefinition
{

View File

@@ -26,7 +26,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
public string ErrorMessage { get; set; }
/// <summary>
/// An info link to navigate to
/// An info link to navigate to
/// </summary>
public string InfoLink { get; set; }
}

View File

@@ -11,7 +11,7 @@ using Microsoft.SqlTools.Extensibility;
namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
{
/// <summary>
/// Extension methods for exportable and service
/// Extension methods for exportable and service
/// </summary>
public static class ExtensionUtils
{
@@ -48,14 +48,14 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
{
return null;
}
//Get all the possible matches
//Get all the possible matches
IEnumerable<T> allMatched = serverDefinition != null ?
exportables.Where(x => Match(x.Metadata, serverDefinition)).ToList() : exportables;
IList<T> list = allMatched.ToList();
//If specific server type requested and the list has any item with that server type remove the others.
//for instance is there's server for all server types and one specifically for sql and give metadata is asking for sql then
//we should return the sql one even if the other service has higher priority
//we should return the sql one even if the other service has higher priority
IList<T> withSameServerType = list.Where(x => serverDefinition.HasSameServerName(x.Metadata)).ToList();
if (withSameServerType.Any())
@@ -101,7 +101,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
}
return false;
}
internal static string GetServerDefinitionKey(this IServerDefinition serverDefinition)
{
string key = string.Empty;
@@ -126,7 +126,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
}
return false;
}
internal static bool EmptyOrEqual(this string value1, string value2)
{
if (string.IsNullOrEmpty(value1) && string.IsNullOrEmpty(value2))
@@ -143,12 +143,12 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// <summary>
/// Returns true if the metadata matches the given server definition
/// </summary>
/// </summary>
public static bool Match(this IServerDefinition first, IServerDefinition other)
{
if (first == null)
{
// TODO should we handle this differently?
// TODO should we handle this differently?
return false;
}
if (other == null)
@@ -158,10 +158,10 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
return MatchMetaData(first.ServerType, other.ServerType)
&& MatchMetaData(first.Category, other.Category);
}
/// <summary>
/// Returns true if the metadata value matches the given value
/// </summary>
/// </summary>
private static bool MatchMetaData(string metaData, string requestedMetaData)
{
if (string.IsNullOrEmpty(metaData) || string.IsNullOrEmpty(requestedMetaData))

View File

@@ -19,7 +19,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
{
set; get;
}
/// <summary>
/// Returns the status of the exportable
/// </summary>

View File

@@ -13,7 +13,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// Provides facility to trace code execution through calls to Trace* methods.
/// Implementing classes must add a <see cref="ExportableAttribute" />
/// to the class in order to be found by the extension manager
/// </summary>
/// </summary>
public interface ITrace : IExportable
{
/// <summary>
@@ -40,5 +40,5 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
bool TraceException(TraceEventType eventType, int traceId, Exception exception, string message,
[CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "",
[CallerMemberName] string memberName = "");
}
}
}

View File

@@ -66,7 +66,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// <summary>
/// Trace Id for network browse traces
/// </summary>
NetworkSection = 11,
NetworkSection = 11,
/// <summary>
/// Trace Id for main dialog traces

View File

@@ -19,13 +19,13 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// </summary>
public abstract ITrace Trace
{
get;
get;
set;
}
/// <summary>
/// Write a trace event message to the underlying trace source.
/// </summary>
/// </summary>
public bool TraceEvent(TraceEventType eventType, TraceId traceId, string format, params object[] args)
{
return TraceEvent(eventType, (int)traceId, format, args);
@@ -33,16 +33,16 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// <summary>
/// Write a trace event message to the underlying trace source.
/// </summary>
/// </summary>
public bool TraceEvent(TraceEventType eventType, int traceId, string format, params object[] args)
{
return SafeTrace(eventType, traceId, format, args);
}
}
/// <summary>
/// Write a formatted trace event message to the underlying trace source and issue a Debug.Fail() call
/// if condition is false.
/// </summary>
/// </summary>
public bool AssertTraceEvent(bool condition, TraceEventType eventType, TraceId traceId, string message)
{
return AssertTraceEvent(condition, eventType, (int)traceId, message);
@@ -51,7 +51,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// <summary>
/// Write a formatted trace event message to the underlying trace source and issue a Debug.Fail() call
/// if condition is false.
/// </summary>
/// </summary>
public bool AssertTraceEvent(bool condition, TraceEventType eventType, int traceId, string message)
{
if (!condition)
@@ -129,7 +129,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
return DebugTraceException(eventType, traceId, exception, message);
}
return true;
}
}
/// <summary>
/// Write a trace event with a message and exception details to the underlying trace source and issue a
@@ -195,7 +195,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// <summary>
/// Verifies ITrace instance is not null before tracing
/// </summary>
/// </summary>
private bool SafeTrace(TraceEventType eventType, int traceId, string format, params object[] args)
{
if (Trace != null)
@@ -207,7 +207,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core.Extensibility
/// <summary>
/// Verifies ITrace instance is not null before tracing the exception
/// </summary>
/// </summary>
private bool SafeTraceException(TraceEventType eventType, int traceId, Exception exception, string message,
[CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "",
[CallerMemberName] string memberName = "")