Skip to content

Commit

Permalink
Automatic code cleanup. (#812)
Browse files Browse the repository at this point in the history
* Sorting/organizing usings.

* Adding missing license notices.

* Adding reformated code.

* Fixing spacing inconsistency.
  • Loading branch information
ivannaranjo authored Oct 2, 2017
1 parent b0cac23 commit 0cd69c1
Show file tree
Hide file tree
Showing 61 changed files with 123 additions and 94 deletions.
2 changes: 1 addition & 1 deletion GoogleCloudExtension/GoogleAnalyticsUtils/HitSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async void SendHitData(Dictionary<string, string> hitData)
}
catch (Exception ex) when (
ex is HttpRequestException ||
ex is TaskCanceledException ) // timeout
ex is TaskCanceledException) // timeout
{ }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ protected static TService GetMockedService<TService, TResource, TRequest, TRespo
where TResource : class
where TRequest : ClientServiceRequest<TResponse>
{

IClientService clientService = GetMockedClientService<TRequest, TResponse>(responses);
TRequest request = GetMockedRequest<TRequest, TResponse>(requestExpression, clientService);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using System.Reflection;
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand All @@ -9,7 +23,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GoogleCloudExtension.DataSources.UnitTests")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyCopyright("Copyright \u00A9 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task<IList<Repo>> ListReposAsync()
},
x => x.Repos,
x => x.NextPageToken);
}
}

/// <summary>
/// Creates a cloud source repository.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public ResourceManagerDataSource(GoogleCredential credential, string appName)
internal ResourceManagerDataSource(
GoogleCredential credential,
Func<BaseClientService.Initializer, CloudResourceManagerService> factory,
string appName) : base(credential, factory, appName) { }
string appName) : base(credential, factory, appName)
{ }

/// <summary>
/// Returns the complete list of projects for the current credentials.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Diagnostics;
using System.IO;

namespace GoogleCloudExtension.Deployment
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ internal static class NetCoreAppUtils
// The mapping of supported .NET Core versions to the base images to use for the Docker image.
private static readonly Dictionary<KnownProjectTypes, string> s_knownRuntimeImages = new Dictionary<KnownProjectTypes, string>
{
[ KnownProjectTypes.NetCoreWebApplication1_0 ] = "gcr.io/google-appengine/aspnetcore:1.0",
[ KnownProjectTypes.NetCoreWebApplication1_1 ] = "gcr.io/google-appengine/aspnetcore:1.1",
[ KnownProjectTypes.NetCoreWebApplication2_0 ] = "gcr.io/google-appengine/aspnetcore:2.0"
[KnownProjectTypes.NetCoreWebApplication1_0] = "gcr.io/google-appengine/aspnetcore:1.0",
[KnownProjectTypes.NetCoreWebApplication1_1] = "gcr.io/google-appengine/aspnetcore:1.1",
[KnownProjectTypes.NetCoreWebApplication2_0] = "gcr.io/google-appengine/aspnetcore:2.0"
};

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
using GoogleCloudExtension.Utils;
using System;
using System.Diagnostics;
using System.Linq;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace GoogleCloudExtension.GitUtils
Expand Down Expand Up @@ -72,16 +72,16 @@ public static async Task<GitRepository> CloneAsync(string url, string localPath)
/// Otherwise false.
/// </returns>
public static bool StoreCredential(
string url,
string refreshToken,
string url,
string refreshToken,
StoreCredentialPathOption pathOption)
{
url.ThrowIfNullOrEmpty(nameof(url));
refreshToken.ThrowIfNullOrEmpty(nameof(refreshToken));

Uri uri = new Uri(url);
UriPartial uriPartial;
switch(pathOption)
switch (pathOption)
{
case StoreCredentialPathOption.UrlPath:
uriPartial = UriPartial.Path;
Expand All @@ -90,7 +90,7 @@ public static bool StoreCredential(
uriPartial = UriPartial.Authority;
break;
default:
throw new ArgumentException(nameof(pathOption));
throw new ArgumentException(nameof(pathOption));
}
return WindowsCredentialManager.Write(
$"git:{uri.GetLeftPart(uriPartial)}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public async Task<IList<string>> GetRemotesUrls()
/// Returns true if the git repository contains the git SHA revision.
/// </summary>
/// <param name="sha">The Git SHA.</param>
public async Task<bool> ContainsCommitAsync(string sha) =>
public async Task<bool> ContainsCommitAsync(string sha) =>
(await ExecCommandAsync($"cat-file -t {sha}"))?.FirstOrDefault() == "commit";

/// <summary>
Expand Down Expand Up @@ -128,7 +128,7 @@ public Task<List<string>> ExecCommandAsync(string command) =>
/// </returns>
public static async Task<bool> IsGitCredentialManagerInstalledAsync() =>
(await GitRepository.RunGitCommandAsync(
"credential-manager version",
"credential-manager version",
Directory.GetCurrentDirectory(),
throwOnError: false)) != null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GoogleCloudExtension.Interop")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyCopyright("Copyright \u00A9 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class PowerShellFailedToConnectException : Exception
/// <summary>
/// This error message indicates it fails to establish connection.
/// </summary>
public const string SessionEmptyErrorMessage =
public const string SessionEmptyErrorMessage =
@"Cannot validate argument on parameter 'Session'. The argument is null or empty.";

public PowerShellFailedToConnectException(Exception innerException) :
public PowerShellFailedToConnectException(Exception innerException) :
base(innerException.Message, innerException)
{ }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async Task<bool> Install(CancellationToken cancelToken)
return await target.ExecuteAsync(AddInstallCommands, cancelToken);
}
catch (Exception ex) when (
ex is ParameterBindingException &&
ex is ParameterBindingException &&
ex.Message.Contains(PowerShellFailedToConnectException.SessionEmptyErrorMessage))
{
throw new PowerShellFailedToConnectException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
using GoogleCloudExtension.Utils;
using Microsoft.TeamFoundation.Controls;
using System;
using System.Diagnostics;
using System.ComponentModel.Composition;
using System.Diagnostics;

namespace GoogleCloudExtension.TeamExplorerExtension
{
Expand All @@ -30,7 +30,7 @@ public class Section : Model, ITeamExplorerSection
{
private const string Guid = "2625FA1D-22DD-440E-87C0-1EB42DB7C5A4";

private ISectionViewModel _viewModel;
private readonly ISectionViewModel _viewModel;
private IServiceProvider _serviceProvider;
private TeamExplorerUtils _teamExploerServices;
private bool _isBusy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public void ShowMessage(string message, ICommand command) =>

public void ShowError(string message) =>
NotificationManager?.ShowNotification(
message,
NotificationType.Error,
NotificationFlags.RequiresConfirmation,
null,
message,
NotificationType.Error,
NotificationFlags.RequiresConfirmation,
null,
default(Guid));

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System;

namespace GoogleCloudExtension.TeamExplorerExtension
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace GoogleCloudExtension.TemplateWizards
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace GoogleCloudExtension.TemplateWizards
{
/// <summary>
Expand All @@ -19,5 +20,5 @@ namespace GoogleCloudExtension.TemplateWizards
/// of problems loading wizards from MEF component assemblies.
/// </summary>
public class GoogleProjectTemplateWizard : DelegatingTemplateWizard<IGoogleProjectTemplateWizard>
{}
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Google Inc.")]
[assembly: AssemblyProduct("TemplateWizards")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyCopyright("Copyright \u00A9 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static AsyncProperty<T> CreateAsyncProperty<TIn, T>(
Task<TIn> valueSource, Func<TIn, T> func, T defaultValue = default(T))
{
return new AsyncProperty<T>(
valueSource.ContinueWith(t => func(GetTaskResultSafe(t))),
valueSource.ContinueWith(t => func(GetTaskResultSafe(t))),
defaultValue);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public static bool Write(
Marshal.FreeCoTaskMem(credential.CredentialBlob);
Marshal.FreeCoTaskMem(credential.UserName);
}

}

[DllImport("Advapi32.dll", EntryPoint = "CredWriteW", CharSet = CharSet.Unicode, SetLastError = true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using GoogleCloudExtension.SolutionUtils;
using System;
using System.Diagnostics;
using GoogleCloudExtension.SolutionUtils;

namespace GoogleCloudExtension.Accounts
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace GoogleCloudExtension.Analytics.Events
{
class GcsFileBrowserNewFolderEvent
internal class GcsFileBrowserNewFolderEvent
{
private const string GcsFileGcsFileBrowserNewFolderEventName = "gcsFileBrowserNewFolder";
private const string DeploymentDurationProperty = "duration";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ public static AnalyticsEvent Create(CommandStatus status)
PubSubSubscriptionCreatedEventName,
CommandStatusUtils.StatusProperty, CommandStatusUtils.GetStatusString(status));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace GoogleCloudExtension.AttachDebuggerDialog
/// </summary>
public class AttachDebuggerFirewallPort
{
private static readonly TimeSpan ConnectivityTestTimeout = TimeSpan.FromSeconds(5);
private static readonly TimeSpan s_connectivityTestTimeout = TimeSpan.FromSeconds(5);
private static readonly TimeSpan s_firewallRuleWaitMaxTime = TimeSpan.FromMinutes(5);
private readonly Lazy<GceDataSource> _lazyDataSource;
private Instance _gceInstance;
Expand Down Expand Up @@ -122,7 +122,7 @@ public async Task<bool> IsPortEnabled()
.SelectMany(x => x.Allowed)
// x is now FireWall.AllowedData
// Check if the allowed protocol is tcp
.Where(x => x?.IPProtocol == "tcp" && x.Ports != null)
.Where(x => x?.IPProtocol == "tcp" && x.Ports != null)
.SelectMany(x => x.Ports)
// x is now port number in string type
// Check if the allowed port number matches
Expand All @@ -148,7 +148,7 @@ public async Task<bool> ConnectivityTest(CancellationToken cancelToken)
try
{
var connectTask = client.ConnectAsync(_gceInstance.GetPublicIpAddress(), PortInfo.Port);
if (connectTask == await Task.WhenAny(connectTask, Task.Delay(ConnectivityTestTimeout, cancelToken)))
if (connectTask == await Task.WhenAny(connectTask, Task.Delay(s_connectivityTestTimeout, cancelToken)))
{
await connectTask;
Debug.WriteLine("ConnectivityTest, Succeeded");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class AttachDebuggerSettings
{
private const int InstancesDefaultUserMaxLength = 10;
private static readonly Lazy<AttachDebuggerSettings> s_instance = new Lazy<AttachDebuggerSettings>();
private static readonly Lazy<List<InstanceDefaultUser>> _lazyDefaultUsersList =
private static readonly Lazy<List<InstanceDefaultUser>> s_lazyDefaultUsersList =
new Lazy<List<InstanceDefaultUser>>(AttachDebuggerSettingsStore.ReadGceInstanceDefaultUsers);
private static List<InstanceDefaultUser> _defaultUsersList => _lazyDefaultUsersList.Value;
private static List<InstanceDefaultUser> _defaultUsersList => s_lazyDefaultUsersList.Value;

/// <summary>
/// Singleton instance.
Expand Down
Loading

0 comments on commit 0cd69c1

Please sign in to comment.