Skip to content

Commit 954fef2

Browse files
committed
Added common .editorconfig settings and applied them.
1 parent a012dc5 commit 954fef2

19 files changed

+75
-70
lines changed

.editorconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Top-most EditorConfig file.
2+
root = true
3+
4+
[*]
5+
end_of_line = crlf
6+
charset = utf-8
7+
insert_final_newline = false
8+
trim_trailing_whitespace = true
9+
10+
[*.cs]
11+
indent_style = tab
12+
dotnet_style_qualification_for_field = false : suggestion
13+
dotnet_style_qualification_for_property = false : suggestion
14+
dotnet_style_qualification_for_method = false : suggestion
15+
dotnet_style_qualification_for_event = false : suggestion
16+
dotnet_style_predefined_type_for_locals_parameters_members = true : suggestion
17+
dotnet_style_predefined_type_for_member_access = true : suggestion
18+
dotnet_style_object_initializer = true : suggestion
19+
dotnet_style_collection_initializer = true : suggestion
20+
dotnet_style_explicit_tuple_names = true : suggestion
21+
dotnet_style_coalesce_expression = true : suggestion
22+
dotnet_style_null_propagation = true : suggestion
23+
csharp_style_var_for_built_in_types = false : suggestion
24+
csharp_style_var_elsewhere = false : suggestion
25+
csharp_style_expression_bodied_properties = true : suggestion
26+
csharp_style_expression_bodied_indexers = true : suggestion
27+
csharp_style_expression_bodied_accessors = true : suggestion
28+
csharp_style_pattern_matching_over_is_with_cast_check = true : suggestion
29+
csharp_style_pattern_matching_over_as_with_null_check = true : suggestion
30+
csharp_style_inlined_variable_declaration = true : suggestion
31+
csharp_style_throw_expression = true : suggestion
32+
csharp_style_conditional_delegate_call = true : suggestion

NET-Standard-Library-Extension.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.25928.0
4+
VisualStudioVersion = 15.0.26014.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E95BAE83-DCB2-4D0C-9466-116BAE563A6B}"
77
EndProject
@@ -13,6 +13,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Whathecode.System.Tests", "
1313
EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{588AAD04-5C01-4A63-9D52-9F6D342C345F}"
1515
ProjectSection(SolutionItems) = preProject
16+
.editorconfig = .editorconfig
1617
.gitignore = .gitignore
1718
.travis.yml = .travis.yml
1819
global.json = global.json

src/Whathecode.System/AbstractInterval.cs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ public IInterval<T> Clamp( IInterval<T> range )
5858
/// <param name = "after">The interval in which to store the part after the point, if any, null otherwise.</param>
5959
public void Split( T atPoint, SplitOption option, out IInterval<T> before, out IInterval<T> after )
6060
{
61-
IInterval<T, T> beforeInner;
62-
IInterval<T, T> afterInner;
63-
Split( atPoint, option, out beforeInner, out afterInner );
61+
Split( atPoint, option, out IInterval<T, T> beforeInner, out IInterval<T, T> afterInner );
6462
before = ReduceGenerics( beforeInner );
6563
after = ReduceGenerics( afterInner );
6664
}
@@ -164,26 +162,22 @@ public abstract partial class AbstractInterval<T, TSize> : IInterval<T, TSize>
164162
/// <summary>
165163
/// The start of the interval.
166164
/// </summary>
167-
public T Start { get { return IsReversed ? _end : _start; } }
168-
165+
public T Start => IsReversed ? _end : _start;
169166
readonly T _end;
170167
/// <summary>
171168
/// The end of the interval.
172169
/// </summary>
173-
public T End { get { return IsReversed ? _start : _end; } }
174-
170+
public T End => IsReversed ? _start : _end;
175171
readonly bool _isStartIncluded;
176172
/// <summary>
177173
/// Is the value at the start of the interval included in the interval.
178174
/// </summary>
179-
public bool IsStartIncluded { get { return IsReversed ? _isEndIncluded : _isStartIncluded; } }
180-
175+
public bool IsStartIncluded => IsReversed ? _isEndIncluded : _isStartIncluded;
181176
readonly bool _isEndIncluded;
182177
/// <summary>
183178
/// Is the value at the end of the interval included in the interval.
184179
/// </summary>
185-
public bool IsEndIncluded { get { return IsReversed ? _isStartIncluded : _isEndIncluded; } }
186-
180+
public bool IsEndIncluded => IsReversed ? _isStartIncluded : _isEndIncluded;
187181
/// <summary>
188182
/// Determines whether the start of the interval lies before or after the end of the interval. true when after, false when before.
189183
/// </summary>
@@ -192,13 +186,11 @@ public abstract partial class AbstractInterval<T, TSize> : IInterval<T, TSize>
192186
/// <summary>
193187
/// Get the value in the center of the interval. Rounded to the nearest correct value.
194188
/// </summary>
195-
public T Center { get { return GetValueAt( 0.5 ); } }
196-
189+
public T Center => GetValueAt( 0.5 );
197190
/// <summary>
198191
/// Get the size of the interval.
199192
/// </summary>
200-
public TSize Size { get { return Subtract( _end, _start ); } }
201-
193+
public TSize Size => Subtract( _end, _start );
202194

203195
/// <summary>
204196
/// Create a new interval with a specified start and end.
@@ -262,7 +254,7 @@ public double GetPercentageFor( T position )
262254
return LiesInInterval( position ) ? 1.0 : -1.0;
263255
}
264256

265-
var positionRange = CreateInstance( Start, true, position, true );
257+
IInterval<T, TSize> positionRange = CreateInstance( Start, true, position, true );
266258
double percentage = Convert( positionRange.Size ) / size;
267259

268260
// Negate percentage when position lies before the interval.
@@ -363,7 +355,7 @@ public T Clamp( T value )
363355
/// <returns>The given range, which excludes all parts lying outside of this range. Null when empty.</returns>
364356
public IInterval<T, TSize> Clamp( IInterval<T, TSize> range )
365357
{
366-
var intersection = Intersection( range );
358+
IInterval<T, TSize> intersection = Intersection( range );
367359
if ( intersection == null )
368360
{
369361
return null;
@@ -381,7 +373,7 @@ public IInterval<T, TSize> Clamp( IInterval<T, TSize> range )
381373

382374
bool thisIsSmaller = _start.CompareTo( range.Start ) <= 0;
383375
bool thisIsBigger = _end.CompareTo( range.End ) >= 0;
384-
var clamped = CreateInstance(
376+
IInterval<T, TSize> clamped = CreateInstance(
385377
thisIsSmaller ? range.Start : _start,
386378
thisIsSmaller ? intersection.IsStartIncluded : _isStartIncluded,
387379
thisIsBigger ? range.End : _end,
@@ -525,7 +517,7 @@ public IInterval<T, TSize> Intersection( IInterval<T, TSize> interval )
525517
int startCompare = _start.CompareTo( interval.Start );
526518
int endCompare = _end.CompareTo( interval.End );
527519

528-
var intersection = CreateInstance(
520+
IInterval<T, TSize> intersection = CreateInstance(
529521
startCompare > 0 ? _start : interval.Start,
530522
startCompare == 0
531523
? _isStartIncluded && interval.IsStartIncluded // On matching boundary, only include when they both include the boundary.
@@ -604,7 +596,7 @@ public IEnumerable<T> GetValues( TSize step, T anchor )
604596
/// <param name = "stepAction">The operation to execute.</param>
605597
public void EveryStepOf( TSize step, Action<T> stepAction )
606598
{
607-
foreach ( var i in GetValues( step ) )
599+
foreach ( T i in GetValues( step ) )
608600
{
609601
stepAction( i );
610602
}
@@ -652,7 +644,7 @@ public IInterval<T, TSize> ExpandTo( T value, bool include )
652644
isEndIncluded |= include;
653645
}
654646

655-
var extended = CreateInstance( start, isStartIncluded, end, isEndIncluded );
647+
IInterval<T, TSize> extended = CreateInstance( start, isStartIncluded, end, isEndIncluded );
656648
return IsReversed ? extended.Reverse() : extended;
657649
}
658650

@@ -715,7 +707,7 @@ public IInterval<T, TSize> Scale( double scale, IInterval<T, TSize> limit, doubl
715707
}
716708
T end = endExceeded ? limit.End : SubtractSize( _end, endSubtraction );
717709

718-
var scaled = CreateInstance( start, _isStartIncluded, end, _isEndIncluded );
710+
IInterval<T, TSize> scaled = CreateInstance( start, _isStartIncluded, end, _isEndIncluded );
719711
return IsReversed ? scaled.Reverse() : scaled;
720712
}
721713

src/Whathecode.System/Algorithm/BinarySearch.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ public static BinarySearchResult<TObject> Search(
5858
if ( !isFinished )
5959
{
6060
// Split interval in the middle.
61-
IInterval<TIndex> smaller, bigger;
62-
range.Split( center, SplitOption.Both, out smaller, out bigger );
61+
range.Split( center, SplitOption.Both, out var smaller, out var bigger );
6362

6463
// Continue recursively in the range in which the object lies.
6564
IInterval<TIndex> inRange = orderToCenter > 0 ? bigger : smaller;
@@ -71,7 +70,7 @@ public static BinarySearchResult<TObject> Search(
7170
TObject bigger = indexOperations.GetByIndex( range.End );
7271

7372
// Find the desired object.
74-
TObject foundObject = default( TObject );
73+
var foundObject = default( TObject );
7574
if ( isObjectFound )
7675
{
7776
foundObject = centerObject;

src/Whathecode.System/Collections/Generic/AbstractEnumerator.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ public T Current
5151
}
5252
}
5353

54-
object IEnumerator.Current
55-
{
56-
get { return Current; }
57-
}
58-
54+
object IEnumerator.Current => Current;
5955

6056
public bool MoveNext()
6157
{

src/Whathecode.System/Collections/Generic/CachedDictionary.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ public class CachedDictionary<TKey, TValue>
2222
/// <param name = "valueInitializer">The delegate to be called to initialize an uncached value for a given key.</param>
2323
public CachedDictionary( Func<TKey, TValue> valueInitializer )
2424
{
25-
if ( valueInitializer == null )
26-
{
27-
throw new ArgumentNullException( nameof( valueInitializer ) );
28-
}
29-
30-
_valueInitializer = valueInitializer;
25+
_valueInitializer = valueInitializer ?? throw new ArgumentNullException( nameof( valueInitializer ) );
3126
}
3227

3328

@@ -40,8 +35,7 @@ public TValue this[ TKey key ]
4035
{
4136
get
4237
{
43-
TValue value;
44-
if ( !_values.TryGetValue( key, out value ) )
38+
if ( !_values.TryGetValue( key, out var value ) )
4539
{
4640
value = _valueInitializer( key );
4741
_values[ key ] = value;

src/Whathecode.System/Collections/Generic/Tree.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ public class Tree<T>
1919
public Tree<T> Parent { get; private set; }
2020

2121
readonly List<Tree<T>> _children = new List<Tree<T>>();
22-
public IEnumerable<Tree<T>> Children
23-
{
24-
get { return _children; }
25-
}
26-
22+
public IEnumerable<Tree<T>> Children => _children;
2723

2824
public Tree( T value )
2925
{
@@ -54,7 +50,7 @@ public Tree<T> AddBranch( IEnumerable<T> branch )
5450
// Leaf doens't exist yet, create full remaining branch.
5551
Tree<T> firstNew = null;
5652
Tree<T> current = this;
57-
foreach ( var leaf in fullBranch )
53+
foreach ( T leaf in fullBranch )
5854
{
5955
current = current.AddLeaf( leaf );
6056
if ( firstNew == null )

src/Whathecode.System/Extensions.Dictionary.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public static partial class Extensions
1717
/// <returns>true when the key was present in the dictionary and the action was performed, false otherwise.</returns>
1818
public static bool TryUseValue<TKey, TValue>( this Dictionary<TKey, TValue> source, TKey key, Action<TValue> useValue )
1919
{
20-
TValue value;
21-
if ( source.TryGetValue( key, out value ) )
20+
if ( source.TryGetValue( key, out TValue value ) )
2221
{
2322
useValue( value );
2423

src/Whathecode.System/Extensions.IEnumerable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void ForEach<T>( this IEnumerable<T> source, Action<T> action )
1919
throw new ArgumentNullException( "All arguments should be non-null." );
2020
}
2121

22-
foreach ( var item in source )
22+
foreach ( T item in source )
2323
{
2424
action( item );
2525
}

src/Whathecode.System/IO/PathHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Linq;
45
using System.Text.RegularExpressions;
@@ -21,7 +22,7 @@ public static class PathHelper
2122
public static string ReplaceInvalidChars( string path, char validChar )
2223
{
2324
// TODO: Separate invalid path chars from invalid filename chars?
24-
var invalidChars = Path.GetInvalidPathChars().Concat( Path.GetInvalidFileNameChars() );
25+
IEnumerable<char> invalidChars = Path.GetInvalidPathChars().Concat( Path.GetInvalidFileNameChars() );
2526

2627
if ( invalidChars.Contains( validChar ) )
2728
{

0 commit comments

Comments
 (0)