Added .editorconfig and fixed some (naming and brace) warnings

This commit is contained in:
Fons 2018-11-22 09:58:07 +01:00
Родитель 43254aeca7
Коммит 4b6cb31be4
6 изменённых файлов: 242 добавлений и 45 удалений

185
.editorconfig Normal file
Просмотреть файл

@ -0,0 +1,185 @@
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
indent_style = space
# New line preferences
end_of_line = crlf
insert_final_newline = false
#### .NET Coding Conventions ####
# this. and Me. preferences
dotnet_style_qualification_for_event = true:silent
dotnet_style_qualification_for_field = true:silent
dotnet_style_qualification_for_method = true:silent
dotnet_style_qualification_for_property = true:silent
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
# Expression-level preferences
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_inlined_variable_declaration = true:silent
csharp_style_throw_expression = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_collection_initializer = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_object_initializer = true:silent
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
# Field preferences
dotnet_style_readonly_field = true:suggestion
#### C# Coding Conventions ####
# var preferences
csharp_style_var_elsewhere = false:suggestion
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = false:suggestion
# Expression-bodied members
csharp_style_expression_bodied_accessors = false:silent
csharp_style_expression_bodied_constructors = false:suggestion
csharp_style_expression_bodied_indexers = false:suggestion
# VS2019 csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = false:silent
# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true:silent
csharp_style_pattern_matching_over_is_with_cast_check = true:silent
# Null-checking preferences
csharp_style_conditional_delegate_call = true:silent
# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
# Code-block preferences
csharp_prefer_braces = true:warning
# Expression-level preferences
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
#### C# Formatting Rules ####
# New line preferences
csharp_new_line_before_catch = false
csharp_new_line_before_else = false
csharp_new_line_before_finally = false
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_open_brace = all
csharp_new_line_between_query_expression_clauses = true
# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
# VS2019 csharp_indent_case_contents_when_block = true
csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true
# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
# VS2019 csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
# Wrapping preferences
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
###############################
# Naming Conventions: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
dotnet_naming_style.camel_case_style.capitalization = camel_case
dotnet_naming_style.I_prefix_style.required_prefix = I
dotnet_naming_style.I_prefix_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = warning
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
# Use PascalCase for public, protected and internal fields
dotnet_naming_rule.pascal_case_for_public_fields.severity = warning
dotnet_naming_rule.pascal_case_for_public_fields.symbols = public_fields
dotnet_naming_rule.pascal_case_for_public_fields.style = pascal_case_style
dotnet_naming_symbols.public_fields.applicable_kinds = field
dotnet_naming_symbols.public_fields.applicable_accessibilities = public,protected,internal
# Interfaces must be PascalCase and have an I prefix
dotnet_naming_rule.interfaces_start_with_I.severity = warning
dotnet_naming_rule.interfaces_start_with_I.symbols = any_interface
dotnet_naming_rule.interfaces_start_with_I.style = I_prefix_style
dotnet_naming_symbols.any_interface.applicable_accessibilities = *
dotnet_naming_symbols.any_interface.applicable_kinds = interface
# Classes, structs, methods, enums, events, properties, namespaces, delegates must be PascalCase
dotnet_naming_rule.general_naming.severity = warning
dotnet_naming_rule.general_naming.symbols = general
dotnet_naming_rule.general_naming.style = pascal_case_style
dotnet_naming_symbols.general.applicable_kinds = class,struct,enum,property,method,event,delegate
dotnet_naming_symbols.general.applicable_accessibilities = *
# Everything else is camelCase
dotnet_naming_rule.everything_else_naming.severity = warning
dotnet_naming_rule.everything_else_naming.symbols = everything_else
dotnet_naming_rule.everything_else_naming.style = camel_case_style
dotnet_naming_symbols.everything_else.applicable_kinds = parameter,field
dotnet_naming_symbols.everything_else.applicable_accessibilities = *

Просмотреть файл

@ -276,22 +276,22 @@ namespace Microsoft.Xaml.Interactions.UnitTests
return true;
}
private EventHandler CanExecuteChangedHandler;
private EventHandler canExecuteChangedHandler;
event EventHandler ICommand.CanExecuteChanged
{
add
{
lock (this.CanExecuteChangedHandler)
lock (this.canExecuteChangedHandler)
{
this.CanExecuteChangedHandler += value;
this.canExecuteChangedHandler += value;
}
}
remove
{
lock (this.CanExecuteChangedHandler)
lock (this.canExecuteChangedHandler)
{
this.CanExecuteChangedHandler -= value;
this.canExecuteChangedHandler -= value;
}
}
}

Просмотреть файл

@ -1,12 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Blend for Visual Studio Version 16
VisualStudioVersion = 16.0.28309.66
# Visual Studio 15
VisualStudioVersion = 15.0.28307.106
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XAMLBehaviorsSample", "XAMLBehaviorsSample\XAMLBehaviorsSample.csproj", "{80AD6652-D782-44F9-808E-56E73F4DC6C6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xaml.Behaviors", "..\..\src\Microsoft.Xaml.Behaviors\Microsoft.Xaml.Behaviors.csproj", "{8620C598-B704-429E-BCA5-7E5DDE506923}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2C4EC773-36C2-4858-AEDB-901F79EEA07A}"
ProjectSection(SolutionItems) = preProject
..\..\.editorconfig = ..\..\.editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

Просмотреть файл

@ -24,7 +24,9 @@ namespace XAMLBehaviorsSample
{
private InvokeCommandControl control;
#pragma warning disable CS0067 // The event is never used
public event EventHandler CanExecuteChanged;
#pragma warning restore CS0067 // The event is never used
public ChangeColorCommand(InvokeCommandControl control)
{

Просмотреть файл

@ -7,16 +7,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Xaml.Behaviors",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "..\Test\UnitTests\UnitTests.csproj", "{76E3CE29-A9BC-4417-8224-CE18C6FE51B4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DFFF3108-79F3-4D4C-BB7E-991E7B1B26A6}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6992F454-F038-4038-938F-DF6CD99A5660}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6992F454-F038-4038-938F-DF6CD99A5660}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6992F454-F038-4038-938F-DF6CD99A5660}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6992F454-F038-4038-938F-DF6CD99A5660}.Release|Any CPU.Build.0 = Release|Any CPU
{8620C598-B704-429E-BCA5-7E5DDE506923}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8620C598-B704-429E-BCA5-7E5DDE506923}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8620C598-B704-429E-BCA5-7E5DDE506923}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -29,6 +30,9 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CE568162-14E0-4A06-892B-DB8C8452253F}
EndGlobalSection
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = BlendSdk.vsmdi
EndGlobalSection

Просмотреть файл

@ -112,9 +112,9 @@ namespace Microsoft.Xaml.Behaviors.Layout
internal static Dictionary<object, TagData> TagDictionary = new Dictionary<object, TagData>();
// timer data to help purge objects we should no longer be tracking
private static DateTime NextToLastPurgeTick = DateTime.MinValue;
private static DateTime LastPurgeTick = DateTime.MinValue;
private static TimeSpan MinTickDelta = TimeSpan.FromSeconds(0.5);
private static DateTime nextToLastPurgeTick = DateTime.MinValue;
private static DateTime lastPurgeTick = DateTime.MinValue;
private static TimeSpan minTickDelta = TimeSpan.FromSeconds(0.5);
protected override void OnAttached()
{
@ -141,13 +141,13 @@ namespace Microsoft.Xaml.Behaviors.Layout
// If we got a notification when elements were deleted, we would maintain a far shorter list of tags whose FEs were deleted since the last purge.
//
// We might also be able to use a WeakReference solution here, but this one is pretty cheap as it only runs when Layout is running anyway.
if (DateTime.Now - LastPurgeTick >= MinTickDelta)
if (DateTime.Now - lastPurgeTick >= minTickDelta)
{
List<object> deadTags = null;
foreach (KeyValuePair<object, TagData> pair in TagDictionary)
{
if (pair.Value.Timestamp < NextToLastPurgeTick)
if (pair.Value.Timestamp < nextToLastPurgeTick)
{
if (deadTags == null)
{
@ -165,8 +165,8 @@ namespace Microsoft.Xaml.Behaviors.Layout
}
}
NextToLastPurgeTick = LastPurgeTick;
LastPurgeTick = DateTime.Now;
nextToLastPurgeTick = lastPurgeTick;
lastPurgeTick = DateTime.Now;
}
if (this.AppliesTo == FluidMoveScope.Self)
@ -351,9 +351,9 @@ namespace Microsoft.Xaml.Behaviors.Layout
/// Identity tag used to detect element motion between containers.
/// </summary>
private static readonly DependencyProperty InitialIdentityTagProperty = DependencyProperty.RegisterAttached("InitialIdentityTag", typeof(object), typeof(FluidMoveBehavior), new PropertyMetadata(null));
private static object GetInitialIdentityTag(DependencyObject obj) { return obj.GetValue(InitialIdentityTagProperty); }
private static void SetInitialIdentityTag(DependencyObject obj, object value) { obj.SetValue(InitialIdentityTagProperty, value); }
private static readonly DependencyProperty initialIdentityTagProperty = DependencyProperty.RegisterAttached("InitialIdentityTag", typeof(object), typeof(FluidMoveBehavior), new PropertyMetadata(null));
private static object GetInitialIdentityTag(DependencyObject obj) { return obj.GetValue(initialIdentityTagProperty); }
private static void SetInitialIdentityTag(DependencyObject obj, object value) { obj.SetValue(initialIdentityTagProperty, value); }
/// <summary>
/// Flag that says whether elements are allowed to float above their containers (in a Popup or Adorner) when changing containers.
@ -397,25 +397,25 @@ namespace Microsoft.Xaml.Behaviors.Layout
/// <summary>
/// Remember the popup/adorner being used, in case of element motion between containers when FloatAbove is true.
/// </summary>
private static readonly DependencyProperty OverlayProperty = DependencyProperty.RegisterAttached("Overlay", typeof(object), typeof(FluidMoveBehavior), new PropertyMetadata(null));
private static object GetOverlay(DependencyObject obj) { return obj.GetValue(OverlayProperty); }
private static void SetOverlay(DependencyObject obj, object value) { obj.SetValue(OverlayProperty, value); }
private static readonly DependencyProperty overlayProperty = DependencyProperty.RegisterAttached("Overlay", typeof(object), typeof(FluidMoveBehavior), new PropertyMetadata(null));
private static object GetOverlay(DependencyObject obj) { return obj.GetValue(overlayProperty); }
private static void SetOverlay(DependencyObject obj, object value) { obj.SetValue(overlayProperty, value); }
/// <summary>
/// Opacity cache used when floating a Popup.
/// </summary>
private static readonly DependencyProperty CacheDuringOverlayProperty = DependencyProperty.RegisterAttached("CacheDuringOverlay", typeof(object), typeof(FluidMoveBehavior), new PropertyMetadata(null));
private static object GetCacheDuringOverlay(DependencyObject obj) { return obj.GetValue(CacheDuringOverlayProperty); }
private static void SetCacheDuringOverlay(DependencyObject obj, object value) { obj.SetValue(CacheDuringOverlayProperty, value); }
private static readonly DependencyProperty cacheDuringOverlayProperty = DependencyProperty.RegisterAttached("CacheDuringOverlay", typeof(object), typeof(FluidMoveBehavior), new PropertyMetadata(null));
private static object GetCacheDuringOverlay(DependencyObject obj) { return obj.GetValue(cacheDuringOverlayProperty); }
private static void SetCacheDuringOverlay(DependencyObject obj, object value) { obj.SetValue(cacheDuringOverlayProperty, value); }
/// <summary>
/// Marks the animation transform.
/// </summary>
private static readonly DependencyProperty HasTransformWrapperProperty = DependencyProperty.RegisterAttached("HasTransformWrapper", typeof(bool), typeof(FluidMoveBehavior), new PropertyMetadata(false));
private static bool GetHasTransformWrapper(DependencyObject obj) { return (bool)obj.GetValue(HasTransformWrapperProperty); }
private static void SetHasTransformWrapper(DependencyObject obj, bool value) { obj.SetValue(HasTransformWrapperProperty, value); }
private static readonly DependencyProperty hasTransformWrapperProperty = DependencyProperty.RegisterAttached("HasTransformWrapper", typeof(bool), typeof(FluidMoveBehavior), new PropertyMetadata(false));
private static bool GetHasTransformWrapper(DependencyObject obj) { return (bool)obj.GetValue(hasTransformWrapperProperty); }
private static void SetHasTransformWrapper(DependencyObject obj, bool value) { obj.SetValue(hasTransformWrapperProperty, value); }
private static Dictionary<object, Storyboard> TransitionStoryboardDictionary = new Dictionary<object, Storyboard>();
private static Dictionary<object, Storyboard> transitionStoryboardDictionary = new Dictionary<object, Storyboard>();
protected override bool ShouldSkipInitialLayout
{
@ -432,10 +432,10 @@ namespace Microsoft.Xaml.Behaviors.Layout
// If we are going to use a binding for the tag, make sure we have one set up.
if (this.InitialTag == TagType.DataContext)
{
object tagValue = child.ReadLocalValue(InitialIdentityTagProperty);
object tagValue = child.ReadLocalValue(initialIdentityTagProperty);
if (!(tagValue is BindingExpression))
{
child.SetBinding(InitialIdentityTagProperty, new Binding(this.InitialTagPath));
child.SetBinding(initialIdentityTagProperty, new Binding(this.InitialTagPath));
}
}
}
@ -490,7 +490,7 @@ namespace Microsoft.Xaml.Behaviors.Layout
FrameworkElement originalChild = child;
if ((!FluidMoveBehavior.IsEmptyRect(previousRect) && !FluidMoveBehavior.IsEmptyRect(newTagData.ParentRect)) && (!IsClose(previousRect.Left, newTagData.ParentRect.Left) || !IsClose(previousRect.Top, newTagData.ParentRect.Top)) ||
(child != tagData.Child && TransitionStoryboardDictionary.ContainsKey(tag)))
(child != tagData.Child && transitionStoryboardDictionary.ContainsKey(tag)))
{
Rect currentRect = previousRect;
bool forceFloatAbove = false;
@ -498,7 +498,7 @@ namespace Microsoft.Xaml.Behaviors.Layout
// If this element was animating before, append its current transform to the start position and kill the old animation.
// Note that in an overlay scenario, the animation is on the image in the overlay.
Storyboard oldTransitionStoryboard = null;
if (TransitionStoryboardDictionary.TryGetValue(tag, out oldTransitionStoryboard))
if (transitionStoryboardDictionary.TryGetValue(tag, out oldTransitionStoryboard))
{
object tagOverlay = GetOverlay(tagData.Child);
AdornerContainer adornerContainer = (AdornerContainer)tagOverlay;
@ -522,7 +522,7 @@ namespace Microsoft.Xaml.Behaviors.Layout
currentRect = transform.TransformBounds(currentRect);
}
TransitionStoryboardDictionary.Remove(tag);
transitionStoryboardDictionary.Remove(tag);
oldTransitionStoryboard.Stop();
oldTransitionStoryboard = null;
RemoveTransform(elementWithTransform);
@ -530,7 +530,7 @@ namespace Microsoft.Xaml.Behaviors.Layout
if (tagOverlay != null)
{
System.Windows.Documents.AdornerLayer.GetAdornerLayer(root).Remove(adornerContainer);
TransferLocalValue(tagData.Child, FluidMoveBehavior.CacheDuringOverlayProperty, FrameworkElement.RenderTransformProperty);
TransferLocalValue(tagData.Child, FluidMoveBehavior.cacheDuringOverlayProperty, FrameworkElement.RenderTransformProperty);
SetOverlay(tagData.Child, null);
}
}
@ -566,7 +566,7 @@ namespace Microsoft.Xaml.Behaviors.Layout
//image.Source = bitmap;
// can't animate this or it will flash, have to set the value outright
TransferLocalValue(child, FrameworkElement.RenderTransformProperty, FluidMoveBehavior.CacheDuringOverlayProperty);
TransferLocalValue(child, FrameworkElement.RenderTransformProperty, FluidMoveBehavior.cacheDuringOverlayProperty);
child.RenderTransform = new TranslateTransform(-10000, -10000);
canvas.RenderTransform = new TranslateTransform(10000, 10000);
@ -579,14 +579,14 @@ namespace Microsoft.Xaml.Behaviors.Layout
Storyboard transitionStoryboard = CreateTransitionStoryboard(child, usingBeforeLoaded, ref parentRect, ref currentRect);
// Put this storyboard in the running dictionary so we can detect reentrancy
TransitionStoryboardDictionary.Add(tag, transitionStoryboard);
transitionStoryboardDictionary.Add(tag, transitionStoryboard);
transitionStoryboard.Completed += delegate (object sender, EventArgs e)
{
Storyboard currentlyRunningStoryboard;
if (TransitionStoryboardDictionary.TryGetValue(tag, out currentlyRunningStoryboard) && currentlyRunningStoryboard == transitionStoryboard)
if (transitionStoryboardDictionary.TryGetValue(tag, out currentlyRunningStoryboard) && currentlyRunningStoryboard == transitionStoryboard)
{
TransitionStoryboardDictionary.Remove(tag);
transitionStoryboardDictionary.Remove(tag);
transitionStoryboard.Stop();
RemoveTransform(child);
child.InvalidateMeasure();
@ -594,7 +594,7 @@ namespace Microsoft.Xaml.Behaviors.Layout
if (overlay != null)
{
System.Windows.Documents.AdornerLayer.GetAdornerLayer(root).Remove((AdornerContainer)overlay);
TransferLocalValue(originalChild, FluidMoveBehavior.CacheDuringOverlayProperty, FrameworkElement.RenderTransformProperty);
TransferLocalValue(originalChild, FluidMoveBehavior.cacheDuringOverlayProperty, FrameworkElement.RenderTransformProperty);
SetOverlay(originalChild, null);
}
}
@ -769,7 +769,10 @@ namespace Microsoft.Xaml.Behaviors.Layout
protected override Size ArrangeOverride(Size finalSize)
{
if (this.child != null)
{
this.child.Arrange(new Rect(finalSize));
}
return finalSize;
}
@ -790,9 +793,7 @@ namespace Microsoft.Xaml.Behaviors.Layout
protected override Visual GetVisualChild(int index)
{
if (index == 0 && this.child != null)
return this.child;
return base.GetVisualChild(index);
return index == 0 && this.child != null ? this.child : base.GetVisualChild(index);
}
}
}