From 5b42151bd4583f387affceaa2228f032b897ca8a Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 2 Feb 2023 09:27:43 -0500 Subject: [PATCH 1/9] Added basic `.editorconfig` file for project coding standards. Left out the additional code formatting rules --- .editorconfig | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d946dde --- /dev/null +++ b/.editorconfig @@ -0,0 +1,132 @@ +# This EditorConfig file provides consistant coding styles and formatting +# structures for your team's projects while preserving your personal defaults. + +# Top-most EditorConfig file +root = true + +# All generic files should use MSDOS style endings, not Unix (lf) +[*] +end_of_line = crlf +indent_style = space + +[*.{cs,csx}] +indent_style = tab +indent_size = 4 +tab_width = 4 +charset = utf-8-bom +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{xml,xaml,axml,axaml}] +indent_style = space +indent_size = 4 +charset = utf-8-bom +trim_trailing_whitespace = true + +[*.xshd] +indent_style = tab +indent_size = 4 +tab_width = 4 +charset = utf-8-bom +trim_trailing_whitespace = true + +[*.json] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[*.sln] +indent_size = 2 + +# Xml project files +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Xml config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# PList Files +[*.plist] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# YAML files +[*.{yaml,yml}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +# Shell script files +[*.sh] +end_of_line = lf +indent_style = space +indent_size = 2 + +# Powershell +[*.{ps1,psd1,psm1}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +# C# Ruleset +[*.{cs,csx}] +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = false +csharp_indent_labels = one_less_than_current +csharp_indent_switch_labels = true + +## Formatting - new line options +### Require braces to be on a new line for (also known as "Allman" style) +### accessors, methods, object_collection, control_blocks, types, properties, lambdas +csharp_new_line_before_open_brace = all +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_between_query_expression_clauses = true + +## Spaces +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_keywords_in_control_flow_statements = true +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_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_parameter_list_parentheses = false + +# Modifier preferences +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion + +# Organize Usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false +dotnet_style_qualification_for_field = false +dotnet_style_qualification_for_method = false +dotnet_style_qualification_for_property = false + From 6cd0f4b07a0591b775a11cf3a8fcd2ee9d2acd50 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 2 Feb 2023 13:40:09 -0500 Subject: [PATCH 2/9] Updated xshd styles to the latest ILSpy. Added missing ILAsm-Mode-Dark syntax highlighting definition --- ILSpy.Core/ILSpy.Core.csproj | 2 +- ILSpy.Core/Themes/CSharp-Mode-Dark.xshd | 106 ++--- ILSpy.Core/Themes/CSharp-Mode.xshd | 35 +- ILSpy.Core/Themes/Dark.xaml | 2 +- ILSpy.Core/Themes/ILAsm-Mode-Dark.xshd | 530 ++++++++++++++++++++++++ ILSpy.Core/Themes/ILAsm-Mode.xshd | 26 +- 6 files changed, 618 insertions(+), 83 deletions(-) create mode 100644 ILSpy.Core/Themes/ILAsm-Mode-Dark.xshd diff --git a/ILSpy.Core/ILSpy.Core.csproj b/ILSpy.Core/ILSpy.Core.csproj index 6840b17..5209875 100644 --- a/ILSpy.Core/ILSpy.Core.csproj +++ b/ILSpy.Core/ILSpy.Core.csproj @@ -59,7 +59,7 @@ - + diff --git a/ILSpy.Core/Themes/CSharp-Mode-Dark.xshd b/ILSpy.Core/Themes/CSharp-Mode-Dark.xshd index 78d79d3..6827931 100644 --- a/ILSpy.Core/Themes/CSharp-Mode-Dark.xshd +++ b/ILSpy.Core/Themes/CSharp-Mode-Dark.xshd @@ -3,49 +3,49 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + - - - + + + - + TODO @@ -56,13 +56,14 @@ UNDONE - + \# - + + (define|undef|if|elif|else|endif|line)\b @@ -72,14 +73,15 @@ - + + (region|endregion|error|warning|pragma)\b - + ///(?!/) @@ -87,16 +89,16 @@ - + // - + /\* \*/ - + " " @@ -105,7 +107,7 @@ - + ' ' @@ -114,7 +116,7 @@ - + @" " @@ -123,7 +125,7 @@ - + \$" " @@ -138,10 +140,10 @@ - \b0[xX][0-9a-fA-F]+ # hex number + \b0[xX][0-9a-fA-F]+ # hex number | - ( \b\d+(\.[0-9]+)? #number with optional floating point - | \.[0-9]+ #or just starting with floating point + ( \b\d+(\.[0-9]+)? #number with optional floating point + | \.[0-9]+ #or just starting with floating point ) ([eE][+-]?[0-9]+)? # optional exponent diff --git a/ILSpy.Core/Themes/CSharp-Mode.xshd b/ILSpy.Core/Themes/CSharp-Mode.xshd index 5f5e0a2..279fdeb 100644 --- a/ILSpy.Core/Themes/CSharp-Mode.xshd +++ b/ILSpy.Core/Themes/CSharp-Mode.xshd @@ -1,9 +1,8 @@ - - + - + @@ -31,7 +30,7 @@ - + @@ -43,9 +42,9 @@ - + - + TODO @@ -56,13 +55,14 @@ UNDONE - + \# - + + (define|undef|if|elif|else|endif|line)\b @@ -72,14 +72,15 @@ - + + (region|endregion|error|warning|pragma)\b - + ///(?!/) @@ -87,16 +88,16 @@ - + // - + /\* \*/ - + " " @@ -105,7 +106,7 @@ - + ' ' @@ -114,7 +115,7 @@ - + @" " @@ -123,7 +124,7 @@ - + \$" " @@ -146,4 +147,4 @@ ([eE][+-]?[0-9]+)? # optional exponent - + \ No newline at end of file diff --git a/ILSpy.Core/Themes/Dark.xaml b/ILSpy.Core/Themes/Dark.xaml index cfb6f3f..57472d3 100644 --- a/ILSpy.Core/Themes/Dark.xaml +++ b/ILSpy.Core/Themes/Dark.xaml @@ -14,7 +14,7 @@ CSharp-Mode-Dark.xshd - ILAsm-Mode.xshd + ILAsm-Mode-Dark.xshd diff --git a/ILSpy.Core/Themes/ILAsm-Mode-Dark.xshd b/ILSpy.Core/Themes/ILAsm-Mode-Dark.xshd new file mode 100644 index 0000000..90c1249 --- /dev/null +++ b/ILSpy.Core/Themes/ILAsm-Mode-Dark.xshd @@ -0,0 +1,530 @@ + + + + + + + + + + + nop + break + ldarg.0 + ldarg.1 + ldarg.2 + ldarg.3 + ldloc.0 + ldloc.1 + ldloc.2 + ldloc.3 + stloc.0 + stloc.1 + stloc.2 + stloc.3 + ldarg.s + ldarga.s + starg.s + ldloc.s + ldloca.s + stloc.s + ldnull + ldc.i4.m1 + ldc.i4.0 + ldc.i4.1 + ldc.i4.2 + ldc.i4.3 + ldc.i4.4 + ldc.i4.5 + ldc.i4.6 + ldc.i4.7 + ldc.i4.8 + ldc.i4.s + ldc.i4 + ldc.i8 + ldc.r4 + ldc.r8 + dup + pop + jmp + call + calli + ret + br.s + brfalse.s + brtrue.s + beq.s + bge.s + bgt.s + ble.s + blt.s + bne.un.s + bge.un.s + bgt.un.s + ble.un.s + blt.un.s + br + brfalse + brtrue + beq + bge + bgt + ble + blt + bne.un + bge.un + bgt.un + ble.un + blt.un + switch + ldind.i1 + ldind.u1 + ldind.i2 + ldind.u2 + ldind.i4 + ldind.u4 + ldind.i8 + ldind.i + ldind.r4 + ldind.r8 + ldind.ref + stind.ref + stind.i1 + stind.i2 + stind.i4 + stind.i8 + stind.r4 + stind.r8 + add + sub + mul + div + div.un + rem + rem.un + and + or + xor + shl + shr + shr.un + neg + not + conv.i1 + conv.i2 + conv.i4 + conv.i8 + conv.r4 + conv.r8 + conv.u4 + conv.u8 + callvirt + cpobj + ldobj + ldstr + newobj + castclass + isinst + conv.r.un + unbox + throw + ldfld + ldflda + stfld + ldsfld + ldsflda + stsfld + stobj + conv.ovf.i1.un + conv.ovf.i2.un + conv.ovf.i4.un + conv.ovf.i8.un + conv.ovf.u1.un + conv.ovf.u2.un + conv.ovf.u4.un + conv.ovf.u8.un + conv.ovf.i.un + conv.ovf.u.un + box + newarr + ldlen + ldelema + ldelem + ldelem.i1 + ldelem.u1 + ldelem.i2 + ldelem.u2 + ldelem.i4 + ldelem.u4 + ldelem.i8 + ldelem.i + ldelem.r4 + ldelem.r8 + ldelem.ref + stelem + stelem.i + stelem.i1 + stelem.i2 + stelem.i4 + stelem.i8 + stelem.r4 + stelem.r8 + stelem.ref + conv.ovf.i1 + conv.ovf.u1 + conv.ovf.i2 + conv.ovf.u2 + conv.ovf.i4 + conv.ovf.u4 + conv.ovf.i8 + conv.ovf.u8 + refanyval + ckfinite + mkrefany + ldtoken + conv.u2 + conv.u1 + conv.i + conv.ovf.i + conv.ovf.u + add.ovf + add.ovf.un + mul.ovf + mul.ovf.un + sub.ovf + sub.ovf.un + endfinally + leave + leave.s + stind.i + conv.u + prefix7 + prefix6 + prefix5 + prefix4 + prefix3 + prefix2 + prefix1 + prefixref + arglist + ceq + cgt + cgt.un + clt + clt.un + ldftn + ldvirtftn + ldarg + ldarga + starg + ldloc + ldloca + stloc + localloc + endfilter + unaligned. + volatile. + tail. + initobj + cpblk + initblk + rethrow + sizeof + refanytype + illegal + endmac + brnull + brnull.s + brzero + brzero.s + brinst + brinst.s + ldind.u8 + ldelem.u8 + ldc.i4.M1 + endfault + + + void + bool + char + wchar + int + int8 + int16 + int32 + int64 + uint8 + uint16 + uint32 + uint64 + float + float32 + float64 + refany + typedref + object + string + native + unsigned + value + valuetype + class + const + vararg + default + stdcall + thiscall + fastcall + unmanaged + not_in_gc_heap + beforefieldinit + instance + filter + catch + static + public + private + synchronized + interface + extends + implements + handler + finally + fault + to + abstract + auto + sequential + explicit + wrapper + ansi + unicode + autochar + import + enum + virtual + notremotable + special + il + cil + optil + managed + preservesig + runtime + method + field + bytearray + final + sealed + specialname + family + assembly + famandassem + famorassem + privatescope + nested + hidebysig + newslot + rtspecialname + pinvokeimpl + unmanagedexp + reqsecobj + .ctor + .cctor + initonly + literal + notserialized + forwardref + internalcall + noinlining + aggressiveinlining + nomangle + lasterr + winapi + cdecl + stdcall + thiscall + fastcall + as + pinned + modreq + modopt + serializable + at + tls + true + false + strict + + + .class + .namespace + .method + .field + .emitbyte + .try + .maxstack + .locals + .entrypoint + .zeroinit + .pdirect + .data + .event + .addon + .removeon + .fire + .other + protected + .property + .set + .get + default + .import + .permission + .permissionset + .line + .language + #line + + + request + demand + assert + deny + permitonly + linkcheck + inheritcheck + reqmin + reqopt + reqrefuse + prejitgrant + prejitdeny + noncasdemand + noncaslinkdemand + noncasinheritance + + + + .custom + + init + + .size + .pack + + .file + nometadata + .hash + .assembly + implicitcom + noappdomain + noprocess + nomachine + .publickey + .publickeytoken + algorithm + .ver + .locale + extern + .export + .manifestres + .mresource + .localized + + + .module + marshal + custom + sysstring + fixed + variant + currency + syschar + decimal + date + bstr + tbstr + lpstr + lpwstr + lptstr + objectref + iunknown + idispatch + struct + safearray + byvalstr + lpvoid + any + array + lpstruct + + + .vtfixup + fromunmanaged + callmostderived + .vtentry + + + in + out + opt + lcid + retval + .param + + + .override + with + + + null + error + hresult + carray + userdefined + record + filetime + blob + stream + storage + streamed_object + stored_object + blob_object + cf + clsid + vector + + + nullref + + + .subsystem + .corflags + .stackreserve + alignment + .imagebase + + + // + + + /\* + \*/ + + + " + " + + + + + TODO + FIXME + + + HACK + UNDONE + + + \ No newline at end of file diff --git a/ILSpy.Core/Themes/ILAsm-Mode.xshd b/ILSpy.Core/Themes/ILAsm-Mode.xshd index 7e5f80b..7a578ce 100644 --- a/ILSpy.Core/Themes/ILAsm-Mode.xshd +++ b/ILSpy.Core/Themes/ILAsm-Mode.xshd @@ -5,7 +5,7 @@ - + nop @@ -149,6 +149,7 @@ newarr ldlen ldelema + ldelem ldelem.i1 ldelem.u1 ldelem.i2 @@ -160,6 +161,7 @@ ldelem.r4 ldelem.r8 ldelem.ref + stelem stelem.i stelem.i1 stelem.i2 @@ -252,10 +254,10 @@ int16 int32 int64 - uint8 - uint16 - uint32 - uint64 + uint8 + uint16 + uint32 + uint64 float float32 float64 @@ -429,7 +431,7 @@ .manifestres .mresource .localized - + .module marshal @@ -456,13 +458,13 @@ any array lpstruct - + .vtfixup fromunmanaged callmostderived .vtentry - + in out @@ -470,11 +472,11 @@ lcid retval .param - + .override with - + null error @@ -492,10 +494,10 @@ cf clsid vector - + nullref - + .subsystem .corflags From 27676a5c36cede7e3392adf6ca8a6b8779b7d00b Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 2 Feb 2023 14:00:19 -0500 Subject: [PATCH 3/9] Updated editorconfig to match ILSpy's --- .editorconfig | 169 ++++++++++++++--------------- ILSpy.Core/Themes/CSharp-Mode.xshd | 2 +- 2 files changed, 80 insertions(+), 91 deletions(-) diff --git a/.editorconfig b/.editorconfig index d946dde..b7d98cf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,132 +1,121 @@ -# This EditorConfig file provides consistant coding styles and formatting -# structures for your team's projects while preserving your personal defaults. - -# Top-most EditorConfig file +; Top-most EditorConfig file root = true -# All generic files should use MSDOS style endings, not Unix (lf) [*] -end_of_line = crlf -indent_style = space - -[*.{cs,csx}] -indent_style = tab -indent_size = 4 -tab_width = 4 -charset = utf-8-bom -trim_trailing_whitespace = true -insert_final_newline = true - -[*.{xml,xaml,axml,axaml}] -indent_style = space -indent_size = 4 -charset = utf-8-bom -trim_trailing_whitespace = true - -[*.xshd] indent_style = tab indent_size = 4 -tab_width = 4 -charset = utf-8-bom -trim_trailing_whitespace = true +guidelines = 110 -[*.json] +[*.il] indent_style = space indent_size = 2 -trim_trailing_whitespace = true - -[*.sln] -indent_size = 2 - -# Xml project files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +[*.{yml,yaml}] indent_style = space indent_size = 2 -trim_trailing_whitespace = true - -# Xml config files -[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +[*.csproj] indent_style = space indent_size = 2 -trim_trailing_whitespace = true - -# PList Files -[*.plist] +[*.config] indent_style = space indent_size = 2 -trim_trailing_whitespace = true - -# YAML files -[*.{yaml,yml}] +[*.nuspec] indent_style = space indent_size = 2 -trim_trailing_whitespace = true - -# Shell script files -[*.sh] -end_of_line = lf +[*.vsixmanifest] indent_style = space indent_size = 2 - -# Powershell -[*.{ps1,psd1,psm1}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true - -[*.md] +[*.vsct] indent_style = space indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true -# C# Ruleset -[*.{cs,csx}] +[*.cs] +# New line preferences +csharp_new_line_before_open_brace = methods, types, control_blocks, local_functions +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = false +csharp_new_line_before_members_in_anonymous_types = false +csharp_new_line_within_query_expression_clauses = false + # Indentation preferences csharp_indent_block_contents = true csharp_indent_braces = false csharp_indent_case_contents = true csharp_indent_case_contents_when_block = false -csharp_indent_labels = one_less_than_current csharp_indent_switch_labels = true +csharp_indent_labels = one_less -## Formatting - new line options -### Require braces to be on a new line for (also known as "Allman" style) -### accessors, methods, object_collection, control_blocks, types, properties, lambdas -csharp_new_line_before_open_brace = all -csharp_new_line_before_catch = true -csharp_new_line_before_else = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_between_query_expression_clauses = true +# Avoid 'this.' in generated code unless absolutely necessary, but allow developers to use it +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_property = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_event = false:silent -## Spaces +# Do not use 'var' when generating code, but allow developers to use it +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent +csharp_style_var_elsewhere = false:silent + +# Use language keywords instead of BCL types when generating code, but allow developers to use either +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent + +# Using directives +dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = true + +# Wrapping +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = false + +# Code style +csharp_prefer_braces = true:silent + +# Expression-level preferences +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion + +# Expression-bodied members +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent + +# Pattern matching +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion + +# Null checking preferences +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion + +# 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 +csharp_space_around_declaration_statements = do_not_ignore 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 - -# Modifier preferences -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion - -# Organize Usings -dotnet_separate_import_directive_groups = false -dotnet_sort_system_directives_first = true -file_header_template = unset - -# this. and Me. preferences -dotnet_style_qualification_for_event = false -dotnet_style_qualification_for_field = false -dotnet_style_qualification_for_method = false -dotnet_style_qualification_for_property = false - +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false diff --git a/ILSpy.Core/Themes/CSharp-Mode.xshd b/ILSpy.Core/Themes/CSharp-Mode.xshd index 279fdeb..f559973 100644 --- a/ILSpy.Core/Themes/CSharp-Mode.xshd +++ b/ILSpy.Core/Themes/CSharp-Mode.xshd @@ -147,4 +147,4 @@ ([eE][+-]?[0-9]+)? # optional exponent - \ No newline at end of file + From 565bff81d31dca972e6559c6349f8e0a6ad3ee07 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 2 Feb 2023 14:42:57 -0500 Subject: [PATCH 4/9] Added display setting for, Highlight Current Line --- ILSpy.Core/Options/DisplaySettings.cs | 20 +++++++++++++++++-- ILSpy.Core/Options/DisplaySettingsPanel.xaml | 1 + .../Options/DisplaySettingsPanel.xaml.cs | 6 ++++-- ILSpy.Core/Properties/Resources.Designer.cs | 19 +++++++++++++----- ILSpy.Core/Properties/Resources.resx | 3 +++ ILSpy.Core/Properties/Resources.zh-Hans.resx | 3 +++ .../TextView/DecompilerTextView.xaml.cs | 19 ++++++++++++++---- 7 files changed, 58 insertions(+), 13 deletions(-) diff --git a/ILSpy.Core/Options/DisplaySettings.cs b/ILSpy.Core/Options/DisplaySettings.cs index 918beea..49bbf77 100644 --- a/ILSpy.Core/Options/DisplaySettings.cs +++ b/ILSpy.Core/Options/DisplaySettings.cs @@ -270,7 +270,22 @@ public bool HighlightMatchingBraces } } - public void CopyValues(DisplaySettings s) + bool highlightCurrentLine = false; + + public bool HighlightCurrentLine + { + get { return highlightCurrentLine; } + set + { + if (highlightCurrentLine != value) + { + highlightCurrentLine = value; + OnPropertyChanged(); + } + } + } + + public void CopyValues(DisplaySettings s) { this.SelectedFont = s.selectedFont; this.SelectedFontSize = s.selectedFontSize; @@ -287,6 +302,7 @@ public void CopyValues(DisplaySettings s) this.IndentationTabSize = s.indentationTabSize; this.IndentationSize = s.indentationSize; this.HighlightMatchingBraces = s.highlightMatchingBraces; - } + this.HighlightCurrentLine = s.highlightCurrentLine; + } } } diff --git a/ILSpy.Core/Options/DisplaySettingsPanel.xaml b/ILSpy.Core/Options/DisplaySettingsPanel.xaml index bbfb8ee..f3db5c4 100644 --- a/ILSpy.Core/Options/DisplaySettingsPanel.xaml +++ b/ILSpy.Core/Options/DisplaySettingsPanel.xaml @@ -68,6 +68,7 @@ + diff --git a/ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs b/ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs index 5540c78..c66dbad 100644 --- a/ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs +++ b/ILSpy.Core/Options/DisplaySettingsPanel.xaml.cs @@ -127,8 +127,9 @@ public static DisplaySettings LoadDisplaySettings(ILSpySettings settings) s.IndentationSize = (int?)e.Attribute("IndentationSize") ?? 4; s.IndentationTabSize = (int?)e.Attribute("IndentationTabSize") ?? 4; s.HighlightMatchingBraces = (bool?)e.Attribute("HighlightMatchingBraces") ?? true; + s.HighlightCurrentLine = (bool?)e.Attribute("HighlightCurrentLine") ?? true; - return s; + return s; } public void Save(XElement root) @@ -151,8 +152,9 @@ public void Save(XElement root) section.SetAttributeValue("IndentationSize", s.IndentationSize); section.SetAttributeValue("IndentationTabSize", s.IndentationTabSize); section.SetAttributeValue("HighlightMatchingBraces", s.HighlightMatchingBraces); + section.SetAttributeValue("HighlightCurrentLine", s.HighlightCurrentLine); - XElement existingElement = root.Element("DisplaySettings"); + XElement existingElement = root.Element("DisplaySettings"); if (existingElement != null) existingElement.ReplaceWith(section); else diff --git a/ILSpy.Core/Properties/Resources.Designer.cs b/ILSpy.Core/Properties/Resources.Designer.cs index af88e18..ab64393 100644 --- a/ILSpy.Core/Properties/Resources.Designer.cs +++ b/ILSpy.Core/Properties/Resources.Designer.cs @@ -1169,11 +1169,20 @@ public static string GeneratePortable { return ResourceManager.GetString("GeneratePortable", resourceCulture); } } - - /// - /// Looks up a localized string similar to Highlight matching braces. - /// - public static string HighlightMatchingBraces { + + /// + /// Looks up a localized string similar to Highlight current line. + /// + public static string HighlightCurrentLine { + get { + return ResourceManager.GetString("HighlightCurrentLine", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Highlight matching braces. + /// + public static string HighlightMatchingBraces { get { return ResourceManager.GetString("HighlightMatchingBraces", resourceCulture); } diff --git a/ILSpy.Core/Properties/Resources.resx b/ILSpy.Core/Properties/Resources.resx index 47b4556..0ce98e1 100644 --- a/ILSpy.Core/Properties/Resources.resx +++ b/ILSpy.Core/Properties/Resources.resx @@ -744,6 +744,9 @@ Are you sure you want to continue? Highlight matching braces + + + Highlight current line Select language to decompile to diff --git a/ILSpy.Core/Properties/Resources.zh-Hans.resx b/ILSpy.Core/Properties/Resources.zh-Hans.resx index 4f04dba..9d22609 100644 --- a/ILSpy.Core/Properties/Resources.zh-Hans.resx +++ b/ILSpy.Core/Properties/Resources.zh-Hans.resx @@ -729,4 +729,7 @@ 搜索MSDN... + + 高亮当前行 + \ No newline at end of file diff --git a/ILSpy.Core/TextView/DecompilerTextView.xaml.cs b/ILSpy.Core/TextView/DecompilerTextView.xaml.cs index addcd2e..8b585e5 100644 --- a/ILSpy.Core/TextView/DecompilerTextView.xaml.cs +++ b/ILSpy.Core/TextView/DecompilerTextView.xaml.cs @@ -118,6 +118,7 @@ public DecompilerTextView() // TemplateApplied += (s,e) => ShowLineMargin(); + SetHighlightCurrentLine(); // add marker service & margin textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); @@ -150,9 +151,14 @@ void RemoveEditCommand(RoutedCommand command) void CurrentDisplaySettings_PropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName == "ShowLineNumbers") { + if (e.PropertyName == nameof(DisplaySettings.ShowLineNumbers)) + { ShowLineMargin(); } + else if (e.PropertyName == nameof(DisplaySettings.HighlightCurrentLine)) + { + SetHighlightCurrentLine(); + } } void ShowLineMargin() @@ -163,11 +169,16 @@ void ShowLineMargin() } } } - + + void SetHighlightCurrentLine() + { + textEditor.Options.HighlightCurrentLine = DisplaySettingsPanel.CurrentDisplaySettings.HighlightCurrentLine; + } + #endregion - + #region Tooltip support - + void TextViewMouseHoverStopped(object sender, PointerEventArgs e) { ToolTip.SetIsOpen(this, false); From bad9dab0ece4b5fbdb5f8e87b8bd1af9370387b1 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 2 Feb 2023 15:12:20 -0500 Subject: [PATCH 5/9] Updated editor background color to match latest theme settings --- ILSpy.Core/TextView/DecompilerTextView.xaml | 4 ++-- ILSpy.Core/Themes/Dark.xaml | 12 +++++++----- ILSpy.Core/Themes/Light.xaml | 8 ++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ILSpy.Core/TextView/DecompilerTextView.xaml b/ILSpy.Core/TextView/DecompilerTextView.xaml index 54e23e4..18a09ea 100644 --- a/ILSpy.Core/TextView/DecompilerTextView.xaml +++ b/ILSpy.Core/TextView/DecompilerTextView.xaml @@ -2,7 +2,7 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:avalonia="clr-namespace:Avalonia;assembly=SharpTreeView" - xmlns:properties="clr-namespace:ICSharpCode.ILSpy.Properties" + xmlns:properties="clr-namespace:ICSharpCode.ILSpy.Properties" xmlns:ae="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit" x:Class="ICSharpCode.ILSpy.TextView.DecompilerTextView"> @@ -12,7 +12,7 @@ Background="{DynamicResource ThemeCodeBackgroundBrush}" Foreground="{DynamicResource ThemeCodeForegroundBrush}"> - + diff --git a/ILSpy.Core/Themes/Dark.xaml b/ILSpy.Core/Themes/Dark.xaml index 57472d3..e921ff5 100644 --- a/ILSpy.Core/Themes/Dark.xaml +++ b/ILSpy.Core/Themes/Dark.xaml @@ -6,12 +6,14 @@ - \ No newline at end of file + From 8eb8de1d6a15a8283e67cf9f9c23d24253fbe24d Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 2 Feb 2023 16:51:35 -0500 Subject: [PATCH 7/9] Workaround for TextMarkerService hiding marked text by passing in an alpha-blended value --- ILSpy.Core/TextView/DecompilerTextView.xaml.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ILSpy.Core/TextView/DecompilerTextView.xaml.cs b/ILSpy.Core/TextView/DecompilerTextView.xaml.cs index 067fb6f..dfc006d 100644 --- a/ILSpy.Core/TextView/DecompilerTextView.xaml.cs +++ b/ILSpy.Core/TextView/DecompilerTextView.xaml.cs @@ -617,10 +617,8 @@ internal void JumpToReference(ReferenceSegment referenceSegment) if (reference.Equals(r.Reference)) { var mark = textMarkerService.Create(r.StartOffset, r.Length); // TODO: Get color from FindResourceKey(...) and NOT hard-coded - // ISSUE: The text disappears, foreground color matches the background // mark.BackgroundColor = (Color)(r.IsDefinition ? FindResource(ResourceKeys.TextMarkerDefinitionBackgroundColor) : FindResource(ResourceKeys.TextMarkerBackgroundColor)); - mark.BackgroundColor = r.IsDefinition ? Colors.LightSeaGreen : Colors.MediumVioletRed; - mark.ForegroundColor = Colors.White; + mark.BackgroundColor = r.IsDefinition ? Color.FromUInt32(0x7720B2AA) : Color.FromUInt32(0x77C71585); // LightSeaGreen : MediumVioletRed; localReferenceMarks.Add(mark); } } From c91b4232195d46c9d9f34f33e8133193cf19a841 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Thu, 2 Feb 2023 17:59:44 -0500 Subject: [PATCH 8/9] Updated text selection brush to be brighter like AvalonEdit versus the darker AvaloniaEdit's default. --- ILSpy.Core/TextView/DecompilerTextView.xaml.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ILSpy.Core/TextView/DecompilerTextView.xaml.cs b/ILSpy.Core/TextView/DecompilerTextView.xaml.cs index dfc006d..a299ad4 100644 --- a/ILSpy.Core/TextView/DecompilerTextView.xaml.cs +++ b/ILSpy.Core/TextView/DecompilerTextView.xaml.cs @@ -123,6 +123,9 @@ public DecompilerTextView() // add marker service & margin textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); + textEditor.TextArea.SelectionBrush = new SolidColorBrush(0x333399FF); + //// textEditor.TextArea.SelectionForeground = new SolidColorBrush(0xFFFFFFFF); + textEditor.TextArea.SelectionBorder = new Pen(0xFF3399ff, 1, null, PenLineCap.Square); } private void InitializeComponent() From 5f8ac0a2db9002284b3ae9f494d9fd18319db5e7 Mon Sep 17 00:00:00 2001 From: Damian Suess Date: Fri, 3 Feb 2023 10:18:29 -0500 Subject: [PATCH 9/9] Code cleanup --- ILSpy.Core/TextView/DecompilerTextView.xaml.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ILSpy.Core/TextView/DecompilerTextView.xaml.cs b/ILSpy.Core/TextView/DecompilerTextView.xaml.cs index a299ad4..4dfe796 100644 --- a/ILSpy.Core/TextView/DecompilerTextView.xaml.cs +++ b/ILSpy.Core/TextView/DecompilerTextView.xaml.cs @@ -123,9 +123,10 @@ public DecompilerTextView() // add marker service & margin textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); + + // Selection highlight. TODO: Pull value from resource key, HighlightColorKey textEditor.TextArea.SelectionBrush = new SolidColorBrush(0x333399FF); - //// textEditor.TextArea.SelectionForeground = new SolidColorBrush(0xFFFFFFFF); - textEditor.TextArea.SelectionBorder = new Pen(0xFF3399ff, 1, null, PenLineCap.Square); + textEditor.TextArea.SelectionBorder = new Pen(color: 0xFF3399ff, thickness: 1); } private void InitializeComponent()