Skip to content

Commit

Permalink
Code CleanUp.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuinox committed Nov 5, 2019
1 parent b92a6cb commit 5debb16
Show file tree
Hide file tree
Showing 141 changed files with 322 additions and 355 deletions.
10 changes: 5 additions & 5 deletions CK.Artifact.Model/Artifact.cs
@@ -1,5 +1,5 @@
using System;
using CSemVer;
using System;

namespace CK.Core
{
Expand Down Expand Up @@ -42,7 +42,7 @@ public Artifact( in ArtifactType type, string name )
if( type == null ) throw new ArgumentNullException( nameof( type ) );
if( String.IsNullOrWhiteSpace( name ) ) throw new ArgumentNullException( nameof( name ) );
Type = type;
Name = name;
Name = name;
}

/// <summary>
Expand Down Expand Up @@ -113,7 +113,7 @@ public static Artifact TryParseOrCreate( string nameOrTypedName, ArtifactType fa
/// </summary>
/// <param name="other">The other artifact.</param>
/// <returns>True when equals, false otherwise.</returns>
public bool Equals( Artifact other ) => Type == other.Type && Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase);
public bool Equals( Artifact other ) => Type == other.Type && Name.Equals( other.Name, StringComparison.OrdinalIgnoreCase );

/// <summary>
/// Overridden to call <see cref="Equals(Artifact)"/>.
Expand All @@ -126,7 +126,7 @@ public static Artifact TryParseOrCreate( string nameOrTypedName, ArtifactType fa
/// Overrsidden to combine <see cref="Type"/> and <see cref="Name"/>.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode() => Type.GetHashCode() ^ StringComparer.OrdinalIgnoreCase.GetHashCode(Name);
public override int GetHashCode() => Type.GetHashCode() ^ StringComparer.OrdinalIgnoreCase.GetHashCode( Name );

/// <summary>
/// Implements == operator.
Expand Down Expand Up @@ -159,7 +159,7 @@ public int CompareTo( Artifact other )
{
if( !IsValid )
{
return other.IsValid ? -1 : 0;
return other.IsValid ? -1 : 0;
}
if( !other.IsValid ) return 1;
int cmp = Type.CompareTo( other.Type );
Expand Down
2 changes: 1 addition & 1 deletion CK.Artifact.Model/ArtifactDependencyKind.cs
Expand Up @@ -26,5 +26,5 @@ public enum ArtifactDependencyKind
/// </summary>
Transitive
}

}
2 changes: 1 addition & 1 deletion CK.Artifact.Model/ArtifactInstance.cs
Expand Up @@ -96,7 +96,7 @@ public static ArtifactInstance TryParse( string instanceName )
if( idx > 0
&& idx < instanceName.Length - 3
&& SVersion.TryParse( instanceName.Substring( idx + 1 ), out var version )
&& Core.Artifact.TryParse( instanceName.Substring(0,idx), out var artifact ) )
&& Core.Artifact.TryParse( instanceName.Substring( 0, idx ), out var artifact ) )
{
return new ArtifactInstance( artifact, version );
}
Expand Down
2 changes: 1 addition & 1 deletion CK.Artifact.Model/ArtifactType.cs
Expand Up @@ -46,7 +46,7 @@ public class ArtifactType : IComparable<ArtifactType>
/// </summary>
/// <param name="name">Type name.</param>
/// <returns>The single registered type.</returns>
public static ArtifactType Single( string name )
public static ArtifactType Single( string name )
{
if( String.IsNullOrWhiteSpace( name ) ) throw new ArgumentNullException( nameof( name ) );
var types = _types;
Expand Down
4 changes: 2 additions & 2 deletions CK.Env.Artifact.NuGet/ArtifactRepository/NuGetClient.cs
Expand Up @@ -139,7 +139,7 @@ internal static void Initalize( NuGetLoggerAdapter logger )
_initialized = true;
}
if( HttpHandlerResourceV3.CredentialService == null )
{
{
var credProviders = new AsyncLazy<IEnumerable<ICredentialProvider>>( async () => await GetCredentialProvidersAsync( logger ) );
HttpHandlerResourceV3.CredentialService = new Lazy<ICredentialService>(
() => new CredentialService(
Expand Down Expand Up @@ -350,7 +350,7 @@ private protected override bool CanRetry( MetadataResource meta, NuGetLoggerAdap
if( String.IsNullOrWhiteSpace( secretOrName ) )
{
logger.Monitor.Trace( "NuGet request failed and there is no Credentials name or password defined. Rethrowing the exception." );
return false;
return false;
}
if( Feed.Credentials.IsSecretKeyName )
{
Expand Down
3 changes: 1 addition & 2 deletions CK.Env.Artifact.NuGet/ArtifactRepository/NuGetFeedBase.cs
@@ -1,6 +1,5 @@
using CK.Core;
using CSemVer;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Protocol.Core.Types;
using System;
Expand Down Expand Up @@ -172,7 +171,7 @@ protected async Task<T> SafeCall<T>( IActivityMonitor m, Func<SourceRepository,
{
_sourceRepository = new SourceRepository( PackageSource, NuGetClient.StaticProviders );
}
again:
again:
MetadataResource meta = null;
try
{
Expand Down
@@ -1,7 +1,6 @@
using CK.Core;
using CK.Text;
using CSemVer;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Packaging.Core;
using NuGet.Protocol.Core.Types;
Expand Down Expand Up @@ -61,7 +60,7 @@ abstract class NuGetRepositoryBase : NuGetFeedBase, INuGetRepository
/// Gets the range of package quality that is accepted by this feed.
/// </summary>
public PackageQualityFilter QualityFilter { get; }

/// <summary>
/// Must provide the secret key name.
/// A null or empty SecretKeyName means that the repository does not require any protection.
Expand All @@ -85,7 +84,7 @@ public virtual string ResolveSecret( IActivityMonitor m, bool throwOnEmpty = fal
if( !String.IsNullOrWhiteSpace( s ) )
{
_secret = Client.SecretKeyStore.GetSecretKey( m, s, throwOnEmpty );
if( _secret != null ) OnSecretResolved( m, _secret );
if( _secret != null ) OnSecretResolved( m, _secret );
}
}
return String.IsNullOrWhiteSpace( _secret ) ? null : _secret;
Expand Down
2 changes: 1 addition & 1 deletion CK.Env.Artifact.NuGet/AzureDevOpsAPIHelper.cs
Expand Up @@ -69,7 +69,7 @@ public static string GetUrl( string projectName, string organization, string fee
IEnumerable<ArtifactInstance> packages,
bool isNPM )
{
string apiUrl = AzureDevOpsAPIHelper.GetUrl(projectName, organization, feedName, isNPM, "packagesBatch", "api-version=5.0-preview.1" );
string apiUrl = AzureDevOpsAPIHelper.GetUrl( projectName, organization, feedName, isNPM, "packagesBatch", "api-version=5.0-preview.1" );
var basicAuth = Convert.ToBase64String( Encoding.ASCII.GetBytes( ":" + personalAccessToken ) );
var byLabels = packages
.SelectMany( p => p.Version.PackageQuality.GetLabels().Select( label => (label, p) ) )
Expand Down
10 changes: 5 additions & 5 deletions CK.Env.Artifact/ArtifactCache/DB/PackageDB.InstanceStore.cs
Expand Up @@ -88,7 +88,7 @@ public void Write( in SerializerContext ctx )
var cc = new Comparable( pInstance => dep.Target.Key.CompareTo( pInstance.Key ) );
// Lookup only from 0 to our index: our dependencies are before us.
Debug.Assert( _instances.AsSpan( 0, i ).BinarySearch( cc ) >= 0 );
ctx.Writer.Write( _instances.AsSpan(0,i).BinarySearch( cc ) );
ctx.Writer.Write( _instances.AsSpan( 0, i ).BinarySearch( cc ) );
}
}
}
Expand All @@ -98,7 +98,7 @@ internal InstanceStore( DeserializerContext ctx, InstanceStore allInstances )
_instances = new PackageInstance[ctx.Reader.ReadInt32()];
for( int i = 0; i < _instances.Length; ++i )
{
_instances[i] = allInstances[ ctx.Reader.ReadInt32() ];
_instances[i] = allInstances[ctx.Reader.ReadInt32()];
}
}

Expand All @@ -124,7 +124,7 @@ public InstanceStore( PackageInstance first )
_instances = new PackageInstance[pLen + 1];
Array.Copy( prev, 0, _instances, 0, idxNewOne );
_instances[idxNewOne] = newOne;
Array.Copy( prev, idxNewOne, _instances, idxNewOne+1, pLen - idxNewOne );
Array.Copy( prev, idxNewOne, _instances, idxNewOne + 1, pLen - idxNewOne );
}

InstanceStore( PackageInstance[] prev, (int idx, PackageInstance p)[] indices )
Expand Down Expand Up @@ -188,7 +188,7 @@ public ArraySegment<PackageInstance> GetInstances( Artifact artifact )
{
readonly Func<PackageInstance, int> _comparer;

public Comparable( Func<PackageInstance,int> comparer )
public Comparable( Func<PackageInstance, int> comparer )
{
_comparer = comparer;
}
Expand All @@ -215,7 +215,7 @@ public int IndexOf( ArtifactInstance instance )

IEnumerator IEnumerable.GetEnumerator() => _instances.GetEnumerator();

ArraySegment<PackageInstance> Range( ArraySegment<PackageInstance> all, Func<PackageInstance,int> comparer )
ArraySegment<PackageInstance> Range( ArraySegment<PackageInstance> all, Func<PackageInstance, int> comparer )
{
Func<PackageInstance, int> rStart = p =>
{
Expand Down
12 changes: 6 additions & 6 deletions CK.Env.Artifact/ArtifactCache/DB/PackageDB.cs
@@ -1,9 +1,9 @@
using System;
using CK.Core;
using System.Collections.Generic;
using System.Linq;
using CK.Text;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace CK.Env
{
Expand Down Expand Up @@ -118,13 +118,13 @@ public PackageDB Add( IActivityMonitor m, IEnumerable<PackageInfo> infos, bool s
else
{
var targets = init.info.Dependencies
.Select( d => ( d.Target,
.Select( d => (d.Target,
_instances.Find( d.Target )
?? initialization
.Take( i )
.Select( t => t.p )
.FirstOrDefault( p => p != null
&& p.Key == d.Target) ) )
&& p.Key == d.Target )) )
.ToArray();
if( targets.Any( t => t.Item2 == null ) )
{
Expand Down Expand Up @@ -183,7 +183,7 @@ public PackageDB Add( IActivityMonitor m, IEnumerable<PackageInfo> infos, bool s
/// <returns></returns>
public PackageDB WithLastUpdate( DateTime t )
{
return t != _lastUpdate ? new PackageDB( this, null, null, t ) : this;
return t != _lastUpdate ? new PackageDB( this, null, null, t ) : this;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion CK.Env.Artifact/ArtifactCache/DB/PackageFeed.cs
Expand Up @@ -37,7 +37,7 @@ internal void Write( PackageDB.InstanceStore allInstances, SerializerContext ctx
{
ctx.Writer.WriteSharedString( _name.Type.Name );
ctx.Writer.Write( _name.Name );
_instances.WriteIndices(ctx, allInstances);
_instances.WriteIndices( ctx, allInstances );
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions CK.Env.Artifact/ArtifactCache/DB/PackageInfo.cs
@@ -1,9 +1,9 @@
using CK.Core;
using CK.Text;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using CK.Core;
using CK.Text;

namespace CK.Env
{
Expand Down Expand Up @@ -70,7 +70,7 @@ Artifact[] Error( string message )
var feedNames = FeedNames.Select( n => Artifact.TryParseOrCreate( n, Key.Artifact.Type ) ).ToArray();
if( feedNames.Any( f => !f.IsValid ) )
{
return Error( $"Invalid feed names found in '{FeedNames.Concatenate("', '")}'." );
return Error( $"Invalid feed names found in '{FeedNames.Concatenate( "', '" )}'." );
}

// Checking dependencies.
Expand Down
6 changes: 3 additions & 3 deletions CK.Env.Artifact/ArtifactCenter.cs
@@ -1,8 +1,8 @@
using CK.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using CK.Core;

namespace CK.Env
{
Expand Down Expand Up @@ -86,11 +86,11 @@ IArtifactRepository InstanciateRepository( in XElementReader r )
return repo;
}

IArtifactFeed InstanciateFeed(IActivityMonitor m, XElementReader r )
IArtifactFeed InstanciateFeed( IActivityMonitor m, XElementReader r )
{
foreach( var h in _typeHandlers )
{
var f = h.CreateFeedFromXML(m, r, _repositories, _feeds );
var f = h.CreateFeedFromXML( m, r, _repositories, _feeds );
if( f != null )
{
if( _feeds.Any( feed => feed.TypedName == f.TypedName ) )
Expand Down
2 changes: 1 addition & 1 deletion CK.Env.Artifact/IArtifactTypeHandler.cs
Expand Up @@ -29,7 +29,7 @@ public interface IArtifactTypeHandler
/// <param name="repositories">The repositories already initialized.</param>
/// <param name="feeds">The feeds already initialized.</param>
/// <returns>The artifact feed or null.</returns>
IArtifactFeed CreateFeedFromXML(IActivityMonitor m, in XElementReader r, IReadOnlyList<IArtifactRepository> repositories, IReadOnlyList<IArtifactFeed> feeds );
IArtifactFeed CreateFeedFromXML( IActivityMonitor m, in XElementReader r, IReadOnlyList<IArtifactRepository> repositories, IReadOnlyList<IArtifactFeed> feeds );

}
}
6 changes: 3 additions & 3 deletions CK.Env.Command/BackgroundCommandAttribute.cs
Expand Up @@ -2,21 +2,21 @@

namespace CK.Env
{
[AttributeUsage(AttributeTargets.Method)]
[AttributeUsage( AttributeTargets.Method )]
public class BackgroundCommandAttribute : Attribute
{

/// <summary>
///
/// </summary>
/// <param name="always">If true the command is runnable in background. If false, it should be asked to the user.</param>
public BackgroundCommandAttribute(bool always = true)
public BackgroundCommandAttribute( bool always = true )
{
AlwaysRunInBackground = always;
}
/// <summary>
/// Gets if the command should be always launched in background. If not it should be asked to the user.
/// </summary>
public bool AlwaysRunInBackground { get;}
public bool AlwaysRunInBackground { get; }
}
}
2 changes: 1 addition & 1 deletion CK.Env.Command/CommandMethodAttribute.cs
Expand Up @@ -2,7 +2,7 @@

namespace CK.Env
{
[AttributeUsage(AttributeTargets.Method)]
[AttributeUsage( AttributeTargets.Method )]
public class CommandMethodAttribute : Attribute
{
public CommandMethodAttribute( bool confirmationRequired = true )
Expand Down
10 changes: 5 additions & 5 deletions CK.Env.Command/CommandRegister.cs
Expand Up @@ -25,7 +25,7 @@ public CommandRegister()
public void Register( ICommandHandler h )
{
if( h.UniqueName.IsEmptyPath
|| h.UniqueName.Path.IndexOfAny( new char[] { '*', '?' } ) >= 0 ) throw new ArgumentException( "Command name must not be empty nor contain '*' or '?'.", nameof(ICommandHandler.UniqueName) );
|| h.UniqueName.Path.IndexOfAny( new char[] { '*', '?' } ) >= 0 ) throw new ArgumentException( "Command name must not be empty nor contain '*' or '?'.", nameof( ICommandHandler.UniqueName ) );
_commands.Add( h.UniqueName, h );
}

Expand All @@ -45,7 +45,7 @@ class MethodHandler : ICommandHandler
readonly Func<bool> _enabled;
readonly ParameterInfo[] _parameters;

public MethodHandler( bool confirmationRequired,bool? parallelRun, bool? backgroundRun, NormalizedPath n, object instance, MethodInfo method, ParameterInfo[] parameters, Func<bool> enabled )
public MethodHandler( bool confirmationRequired, bool? parallelRun, bool? backgroundRun, NormalizedPath n, object instance, MethodInfo method, ParameterInfo[] parameters, Func<bool> enabled )
{
ConfirmationRequired = confirmationRequired;
UniqueName = n;
Expand All @@ -54,7 +54,7 @@ public MethodHandler( bool confirmationRequired,bool? parallelRun, bool? backgro
_parameters = parameters;
PayloadSignature = parameters.Length == 1
? null
: '(' + parameters.Skip(1).Select( p => p.Name ).Concatenate() + ')';
: '(' + parameters.Skip( 1 ).Select( p => p.Name ).Concatenate() + ')';
_enabled = enabled;
ParallelRun = parallelRun;
BackgroundRun = backgroundRun;
Expand Down Expand Up @@ -147,7 +147,7 @@ public ICommandHandler Register( bool confirmationRequired, NormalizedPath uniqu
public void Register( ICommandMethodsProvider provider )
{
var methods = provider?.GetType().GetMethods() ?? throw new ArgumentNullException( nameof( provider ) );
foreach( var m in methods )
foreach( var m in methods )
{
var attr = m.GetCustomAttribute<CommandMethodAttribute>();
if( attr != null )
Expand Down Expand Up @@ -192,7 +192,7 @@ public void Unregister( ICommandMethodsProvider provider )
/// Unregisters all commands, optionally keeping some of them.
/// </summary>
/// <param name="keepFilter">Optional function that can return true to keep the handler registered.</param>
public void UnregisterAll( Func<ICommandHandler,bool> keepFilter = null )
public void UnregisterAll( Func<ICommandHandler, bool> keepFilter = null )
{
if( keepFilter == null ) _commands.Clear();
else
Expand Down
4 changes: 2 additions & 2 deletions CK.Env.Command/SimplePayload.cs
Expand Up @@ -6,7 +6,7 @@

namespace CK.Env
{
public class SimplePayload
public class SimplePayload
{
public class Field
{
Expand All @@ -31,7 +31,7 @@ public void SetValue( object value )
/// or <see cref="Type.Missing"/> if there is noi value set nor default.
/// </summary>
/// <returns>The value or the missing type marker.</returns>
public object GetValue() => IsValueSet ? _value : Type.Missing;
public object GetValue() => IsValueSet ? _value : Type.Missing;

public Field( string name, Type type, bool hasDefaultValue, object defaultValue, bool isPassword = false )
{
Expand Down
2 changes: 1 addition & 1 deletion CK.Env.DependencyModel/DependencyAnalyzer.cs
Expand Up @@ -453,7 +453,7 @@ internal static DependencyAnalyzer Create( IActivityMonitor m, IReadOnlyCollecti
{
if( packages.TryGetValue( package.Artifact, out var alreadyPublished ) )
{
m.Error( $"'{package.Project.Solution+"->"+package}' is already published by {alreadyPublished.Project.Solution+"->"+alreadyPublished.Project}." );
m.Error( $"'{package.Project.Solution + "->" + package}' is already published by {alreadyPublished.Project.Solution + "->" + alreadyPublished.Project}." );
return null;
}
packages.Add( package.Artifact, new LocalPackageItem( package.Artifact, project ) );
Expand Down
2 changes: 1 addition & 1 deletion CK.Env.DependencyModel/IProject.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using CK.Core;
using CK.Text;
using System.Collections.Generic;

namespace CK.Env.DependencyModel
{
Expand Down

0 comments on commit 5debb16

Please sign in to comment.