Browse Source

Override syntax colors from theme dictionary

pull/2906/head
Lucas Trzesniewski 2 years ago
parent
commit
aa0abcdd51
  1. 4
      ILSpy/ILSpy.csproj
  2. 1211
      ILSpy/TextView/Asm-Mode-Dark.xshd
  3. 149
      ILSpy/TextView/CSharp-Mode-Dark.xshd
  4. 13
      ILSpy/TextView/DecompilerTextView.cs
  5. 530
      ILSpy/TextView/ILAsm-Mode-Dark.xshd
  6. 63
      ILSpy/TextView/XML-Mode-Dark.xshd
  7. 69
      ILSpy/Themes/DarkTheme.xaml
  8. 31
      ILSpy/Themes/SyntaxColor.cs
  9. 52
      ILSpy/Themes/ThemeManager.cs

4
ILSpy/ILSpy.csproj

@ -69,10 +69,6 @@ @@ -69,10 +69,6 @@
<EmbeddedResource Include="TextView\ILAsm-Mode.xshd" />
<EmbeddedResource Include="TextView\Asm-Mode.xshd" />
<EmbeddedResource Include="TextView\XML-Mode.xshd" />
<EmbeddedResource Include="TextView\CSharp-Mode-Dark.xshd" />
<EmbeddedResource Include="TextView\ILAsm-Mode-Dark.xshd" />
<EmbeddedResource Include="TextView\Asm-Mode-Dark.xshd" />
<EmbeddedResource Include="TextView\XML-Mode-Dark.xshd" />
<None Remove="Properties\launchSettings.json" />
</ItemGroup>

1211
ILSpy/TextView/Asm-Mode-Dark.xshd

File diff suppressed because it is too large Load Diff

149
ILSpy/TextView/CSharp-Mode-Dark.xshd

@ -1,149 +0,0 @@ @@ -1,149 +0,0 @@
<?xml version="1.0"?>
<SyntaxDefinition name="C#" extensions=".cs" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<!-- This is a variant of the AvalonEdit C# highlighting that has several constructs disabled.
The disabled constructs (e.g. contextual keywords) are highlighted using the CSharpLanguage.HighlightingTokenWriter instead.
-->
<!-- The named colors 'Comment' and 'String' are used in SharpDevelop to detect if a line is inside a multiline string/comment -->
<Color name="Comment" foreground="#FF57A64A" exampleText="// comment" />
<Color name="String" foreground="#FFD69D85" exampleText="string text = &quot;Hello, World!&quot;"/>
<Color name="StringInterpolation" foreground="#FFffd68f" exampleText="string text = $&quot;Hello, {name}!&quot;"/>
<Color name="Char" foreground="#FFD69D85" exampleText="char linefeed = '\n';"/>
<Color name="Preprocessor" foreground="#FF9B9B9B" exampleText="#region Title"/>
<Color name="Punctuation" foreground="White" exampleText="a(b.c);"/>
<Color name="ValueTypeKeywords" foreground="#FF00A0FF" exampleText="bool b = true;"/>
<Color name="ReferenceTypeKeywords" foreground="#FF559CD6" exampleText="object o;"/>
<Color name="NumberLiteral" foreground="#FFb5cea8" exampleText="3.1415f"/>
<Color name="ThisOrBaseReference" foreground="#FF3a6a9b" exampleText="this.Do(); base.Do();"/>
<Color name="NullOrValueKeywords" foreground="#FF559CD6" exampleText="if (value == null)"/>
<Color name="Keywords" foreground="#FFd8a0df" exampleText="if (a) {} else {}"/>
<Color name="GotoKeywords" foreground="#FFd8a0df" exampleText="continue; return null;"/>
<Color name="QueryKeywords" foreground="#FFd8a0df" exampleText="var a = from x in y select z;"/>
<Color name="ExceptionKeywords" foreground="#FFd8a0df" exampleText="try {} catch {} finally {}"/>
<Color name="CheckedKeyword" foreground="#FF559CD6" exampleText="checked {}"/>
<Color name="UnsafeKeywords" foreground="#FF559CD6" exampleText="unsafe { fixed (..) {} }"/>
<Color name="OperatorKeywords" foreground="#FFD69D85" exampleText="public static implicit operator..."/>
<Color name="ParameterModifiers" foreground="#FF559CD6" exampleText="(ref int a, params int[] b)"/>
<Color name="Modifiers" foreground="#FF559CD6" exampleText="static readonly int a;"/>
<Color name="Visibility" foreground="#FF559CD6" exampleText="public override void ToString();"/>
<Color name="NamespaceKeywords" foreground="#FF559CD6" exampleText="namespace A.B { using System; }"/>
<Color name="GetSetAddRemove" foreground="#FF559CD6" exampleText="int Prop { get; set; }"/>
<Color name="TrueFalse" foreground="#FF00A0FF" exampleText="b = false; a = true;"/>
<Color name="TypeKeywords" foreground="#FF559CD6" exampleText="if (x is int) { a = x as int; type = typeof(int); size = sizeof(int); c = new object(); }"/>
<Color name="AttributeKeywords" foreground="#FFD69D85" exampleText="[assembly: AssemblyVersion(&quot;1.0.0.*&quot;)]" />
<!-- Colors used for semantic highlighting -->
<Color name="ReferenceTypes" foreground="#569CD6" exampleText="System.#{#Uri#}# uri;"/>
<Color name="InterfaceTypes" foreground="#569CD6" exampleText="System.#{#IDisposable#}# obj;"/>
<Color name="TypeParameters" foreground="#569CD6" exampleText="class MyList&lt;#{#T#}#&gt; { }"/>
<Color name="DelegateTypes" foreground="#569CD6" exampleText="System.#{#Action#}#; action;"/>
<Color name="ValueTypes" fontWeight="bold" foreground="#569CD6" exampleText="System.#{#DateTime#}# date;"/>
<Color name="EnumTypes" fontWeight="bold" foreground="#569CD6" exampleText="System.#{#ConsoleKey#}# key;"/>
<Color name="MethodCall" foreground="#FFdcdcaa" fontWeight="bold" exampleText="o.#{#ToString#}#();"/>
<Color name="FieldAccess" fontStyle="italic" exampleText="return this.#{#name#}#;"/>
<Color name="InactiveCode" foreground="Gray" exampleText="#{#Deactivated by #if#}#"/>
<Color name="SemanticError" foreground="DarkRed" exampleText="o.#{#MissingMethod#}#()"/>
<Property name="DocCommentMarker" value="///" />
<RuleSet name="CommentMarkerSet">
<Keywords fontWeight="bold" foreground="Red">
<Word>TODO</Word>
<Word>FIXME</Word>
</Keywords>
<Keywords fontWeight="bold" foreground="#E0E000">
<Word>HACK</Word>
<Word>UNDONE</Word>
</Keywords>
</RuleSet>
<!-- This is the main ruleset. -->
<RuleSet>
<Span color="Preprocessor">
<Begin>\#</Begin>
<RuleSet name="PreprocessorSet">
<Span> <!-- preprocessor directives that allow comments -->
<Begin fontWeight="bold">
(define|undef|if|elif|else|endif|line)\b
</Begin>
<RuleSet>
<Span color="Comment" ruleSet="CommentMarkerSet">
<Begin>//</Begin>
</Span>
</RuleSet>
</Span>
<Span> <!-- preprocessor directives that don't allow comments -->
<Begin fontWeight="bold">
(region|endregion|error|warning|pragma)\b
</Begin>
</Span>
</RuleSet>
</Span>
<Span color="Comment">
<Begin color="XmlDoc/DocComment">///(?!/)</Begin>
<RuleSet>
<Import ruleSet="XmlDoc/DocCommentSet"/>
<Import ruleSet="CommentMarkerSet"/>
</RuleSet>
</Span>
<Span color="Comment" ruleSet="CommentMarkerSet">
<Begin>//</Begin>
</Span>
<Span color="Comment" ruleSet="CommentMarkerSet" multiline="true">
<Begin>/\*</Begin>
<End>\*/</End>
</Span>
<Span color="String">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<!-- span for escape sequences -->
<Span begin="\\" end="."/>
</RuleSet>
</Span>
<Span color="Char">
<Begin>'</Begin>
<End>'</End>
<RuleSet>
<!-- span for escape sequences -->
<Span begin="\\" end="."/>
</RuleSet>
</Span>
<Span color="String" multiline="true">
<Begin color="String">@"</Begin>
<End>"</End>
<RuleSet>
<!-- span for escape sequences -->
<Span begin='""' end=""/>
</RuleSet>
</Span>
<Span color="String">
<Begin>\$"</Begin>
<End>"</End>
<RuleSet>
<!-- span for escape sequences -->
<Span begin="\\" end="."/>
<Span begin="\{\{" end=""/>
<!-- string interpolation -->
<Span begin="{" end="}" color="StringInterpolation" ruleSet=""/>
</RuleSet>
</Span>
<!-- Digits -->
<Rule color="NumberLiteral">
\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
)
([eE][+-]?[0-9]+)? # optional exponent
</Rule>
</RuleSet>
</SyntaxDefinition>

13
ILSpy/TextView/DecompilerTextView.cs

@ -1364,15 +1364,8 @@ namespace ICSharpCode.ILSpy.TextView @@ -1364,15 +1364,8 @@ namespace ICSharpCode.ILSpy.TextView
string[] extensions,
string resourceName)
{
if (ThemeManager.Current.Theme == "Dark")
{
resourceName += "-Dark";
}
resourceName += ".xshd";
Stream? resourceStream = typeof(DecompilerTextView).Assembly
.GetManifestResourceStream(typeof(DecompilerTextView), resourceName);
.GetManifestResourceStream(typeof(DecompilerTextView), resourceName + ".xshd");
if (resourceStream != null)
{
@ -1382,7 +1375,9 @@ namespace ICSharpCode.ILSpy.TextView @@ -1382,7 +1375,9 @@ namespace ICSharpCode.ILSpy.TextView
using (resourceStream)
using (XmlTextReader reader = new XmlTextReader(resourceStream))
{
return HighlightingLoader.Load(reader, manager);
var highlightingDefinition = HighlightingLoader.Load(reader, manager);
ThemeManager.Current.UpdateColors(highlightingDefinition);
return highlightingDefinition;
}
});
}

530
ILSpy/TextView/ILAsm-Mode-Dark.xshd

@ -1,530 +0,0 @@ @@ -1,530 +0,0 @@
<SyntaxDefinition name="ILAsm" extensions=".il" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="#FF57A64A" exampleText="// comment" />
<Color name="String" foreground="#FFD69D85" exampleText="&quot;Hello, World!&quot;" />
<Color name="Instructions" foreground="#FFD69D85" exampleText="nop;" />
<Color name="Keywords" foreground="#FFD69D85" fontWeight="bold" exampleText="true" />
<Color name="Directives" foreground="#FF57A64A" fontWeight="bold" exampleText=".class" />
<Color name="Security" foreground="#FF559CD6" exampleText="request" />
<RuleSet ignoreCase="false">
<Keywords color="Instructions">
<Word>nop</Word>
<Word>break</Word>
<Word>ldarg.0</Word>
<Word>ldarg.1</Word>
<Word>ldarg.2</Word>
<Word>ldarg.3</Word>
<Word>ldloc.0</Word>
<Word>ldloc.1</Word>
<Word>ldloc.2</Word>
<Word>ldloc.3</Word>
<Word>stloc.0</Word>
<Word>stloc.1</Word>
<Word>stloc.2</Word>
<Word>stloc.3</Word>
<Word>ldarg.s</Word>
<Word>ldarga.s</Word>
<Word>starg.s</Word>
<Word>ldloc.s</Word>
<Word>ldloca.s</Word>
<Word>stloc.s</Word>
<Word>ldnull</Word>
<Word>ldc.i4.m1</Word>
<Word>ldc.i4.0</Word>
<Word>ldc.i4.1</Word>
<Word>ldc.i4.2</Word>
<Word>ldc.i4.3</Word>
<Word>ldc.i4.4</Word>
<Word>ldc.i4.5</Word>
<Word>ldc.i4.6</Word>
<Word>ldc.i4.7</Word>
<Word>ldc.i4.8</Word>
<Word>ldc.i4.s</Word>
<Word>ldc.i4</Word>
<Word>ldc.i8</Word>
<Word>ldc.r4</Word>
<Word>ldc.r8</Word>
<Word>dup</Word>
<Word>pop</Word>
<Word>jmp</Word>
<Word>call</Word>
<Word>calli</Word>
<Word>ret</Word>
<Word>br.s</Word>
<Word>brfalse.s</Word>
<Word>brtrue.s</Word>
<Word>beq.s</Word>
<Word>bge.s</Word>
<Word>bgt.s</Word>
<Word>ble.s</Word>
<Word>blt.s</Word>
<Word>bne.un.s</Word>
<Word>bge.un.s</Word>
<Word>bgt.un.s</Word>
<Word>ble.un.s</Word>
<Word>blt.un.s</Word>
<Word>br</Word>
<Word>brfalse</Word>
<Word>brtrue</Word>
<Word>beq</Word>
<Word>bge</Word>
<Word>bgt</Word>
<Word>ble</Word>
<Word>blt</Word>
<Word>bne.un</Word>
<Word>bge.un</Word>
<Word>bgt.un</Word>
<Word>ble.un</Word>
<Word>blt.un</Word>
<Word>switch</Word>
<Word>ldind.i1</Word>
<Word>ldind.u1</Word>
<Word>ldind.i2</Word>
<Word>ldind.u2</Word>
<Word>ldind.i4</Word>
<Word>ldind.u4</Word>
<Word>ldind.i8</Word>
<Word>ldind.i</Word>
<Word>ldind.r4</Word>
<Word>ldind.r8</Word>
<Word>ldind.ref</Word>
<Word>stind.ref</Word>
<Word>stind.i1</Word>
<Word>stind.i2</Word>
<Word>stind.i4</Word>
<Word>stind.i8</Word>
<Word>stind.r4</Word>
<Word>stind.r8</Word>
<Word>add</Word>
<Word>sub</Word>
<Word>mul</Word>
<Word>div</Word>
<Word>div.un</Word>
<Word>rem</Word>
<Word>rem.un</Word>
<Word>and</Word>
<Word>or</Word>
<Word>xor</Word>
<Word>shl</Word>
<Word>shr</Word>
<Word>shr.un</Word>
<Word>neg</Word>
<Word>not</Word>
<Word>conv.i1</Word>
<Word>conv.i2</Word>
<Word>conv.i4</Word>
<Word>conv.i8</Word>
<Word>conv.r4</Word>
<Word>conv.r8</Word>
<Word>conv.u4</Word>
<Word>conv.u8</Word>
<Word>callvirt</Word>
<Word>cpobj</Word>
<Word>ldobj</Word>
<Word>ldstr</Word>
<Word>newobj</Word>
<Word>castclass</Word>
<Word>isinst</Word>
<Word>conv.r.un</Word>
<Word>unbox</Word>
<Word>throw</Word>
<Word>ldfld</Word>
<Word>ldflda</Word>
<Word>stfld</Word>
<Word>ldsfld</Word>
<Word>ldsflda</Word>
<Word>stsfld</Word>
<Word>stobj</Word>
<Word>conv.ovf.i1.un</Word>
<Word>conv.ovf.i2.un</Word>
<Word>conv.ovf.i4.un</Word>
<Word>conv.ovf.i8.un</Word>
<Word>conv.ovf.u1.un</Word>
<Word>conv.ovf.u2.un</Word>
<Word>conv.ovf.u4.un</Word>
<Word>conv.ovf.u8.un</Word>
<Word>conv.ovf.i.un</Word>
<Word>conv.ovf.u.un</Word>
<Word>box</Word>
<Word>newarr</Word>
<Word>ldlen</Word>
<Word>ldelema</Word>
<Word>ldelem</Word>
<Word>ldelem.i1</Word>
<Word>ldelem.u1</Word>
<Word>ldelem.i2</Word>
<Word>ldelem.u2</Word>
<Word>ldelem.i4</Word>
<Word>ldelem.u4</Word>
<Word>ldelem.i8</Word>
<Word>ldelem.i</Word>
<Word>ldelem.r4</Word>
<Word>ldelem.r8</Word>
<Word>ldelem.ref</Word>
<Word>stelem</Word>
<Word>stelem.i</Word>
<Word>stelem.i1</Word>
<Word>stelem.i2</Word>
<Word>stelem.i4</Word>
<Word>stelem.i8</Word>
<Word>stelem.r4</Word>
<Word>stelem.r8</Word>
<Word>stelem.ref</Word>
<Word>conv.ovf.i1</Word>
<Word>conv.ovf.u1</Word>
<Word>conv.ovf.i2</Word>
<Word>conv.ovf.u2</Word>
<Word>conv.ovf.i4</Word>
<Word>conv.ovf.u4</Word>
<Word>conv.ovf.i8</Word>
<Word>conv.ovf.u8</Word>
<Word>refanyval</Word>
<Word>ckfinite</Word>
<Word>mkrefany</Word>
<Word>ldtoken</Word>
<Word>conv.u2</Word>
<Word>conv.u1</Word>
<Word>conv.i</Word>
<Word>conv.ovf.i</Word>
<Word>conv.ovf.u</Word>
<Word>add.ovf</Word>
<Word>add.ovf.un</Word>
<Word>mul.ovf</Word>
<Word>mul.ovf.un</Word>
<Word>sub.ovf</Word>
<Word>sub.ovf.un</Word>
<Word>endfinally</Word>
<Word>leave</Word>
<Word>leave.s</Word>
<Word>stind.i</Word>
<Word>conv.u</Word>
<Word>prefix7</Word>
<Word>prefix6</Word>
<Word>prefix5</Word>
<Word>prefix4</Word>
<Word>prefix3</Word>
<Word>prefix2</Word>
<Word>prefix1</Word>
<Word>prefixref</Word>
<Word>arglist</Word>
<Word>ceq</Word>
<Word>cgt</Word>
<Word>cgt.un</Word>
<Word>clt</Word>
<Word>clt.un</Word>
<Word>ldftn</Word>
<Word>ldvirtftn</Word>
<Word>ldarg</Word>
<Word>ldarga</Word>
<Word>starg</Word>
<Word>ldloc</Word>
<Word>ldloca</Word>
<Word>stloc</Word>
<Word>localloc</Word>
<Word>endfilter</Word>
<Word>unaligned.</Word>
<Word>volatile.</Word>
<Word>tail.</Word>
<Word>initobj</Word>
<Word>cpblk</Word>
<Word>initblk</Word>
<Word>rethrow</Word>
<Word>sizeof</Word>
<Word>refanytype</Word>
<Word>illegal</Word>
<Word>endmac</Word>
<Word>brnull</Word>
<Word>brnull.s</Word>
<Word>brzero</Word>
<Word>brzero.s</Word>
<Word>brinst</Word>
<Word>brinst.s</Word>
<Word>ldind.u8</Word>
<Word>ldelem.u8</Word>
<Word>ldc.i4.M1</Word>
<Word>endfault</Word>
</Keywords>
<Keywords color="Keywords">
<Word>void</Word>
<Word>bool</Word>
<Word>char</Word>
<Word>wchar</Word>
<Word>int</Word>
<Word>int8</Word>
<Word>int16</Word>
<Word>int32</Word>
<Word>int64</Word>
<Word>uint8</Word>
<Word>uint16</Word>
<Word>uint32</Word>
<Word>uint64</Word>
<Word>float</Word>
<Word>float32</Word>
<Word>float64</Word>
<Word>refany</Word>
<Word>typedref</Word>
<Word>object</Word>
<Word>string</Word>
<Word>native</Word>
<Word>unsigned</Word>
<Word>value</Word>
<Word>valuetype</Word>
<Word>class</Word>
<Word>const</Word>
<Word>vararg</Word>
<Word>default</Word>
<Word>stdcall</Word>
<Word>thiscall</Word>
<Word>fastcall</Word>
<Word>unmanaged</Word>
<Word>not_in_gc_heap</Word>
<Word>beforefieldinit</Word>
<Word>instance</Word>
<Word>filter</Word>
<Word>catch</Word>
<Word>static</Word>
<Word>public</Word>
<Word>private</Word>
<Word>synchronized</Word>
<Word>interface</Word>
<Word>extends</Word>
<Word>implements</Word>
<Word>handler</Word>
<Word>finally</Word>
<Word>fault</Word>
<Word>to</Word>
<Word>abstract</Word>
<Word>auto</Word>
<Word>sequential</Word>
<Word>explicit</Word>
<Word>wrapper</Word>
<Word>ansi</Word>
<Word>unicode</Word>
<Word>autochar</Word>
<Word>import</Word>
<Word>enum</Word>
<Word>virtual</Word>
<Word>notremotable</Word>
<Word>special</Word>
<Word>il</Word>
<Word>cil</Word>
<Word>optil</Word>
<Word>managed</Word>
<Word>preservesig</Word>
<Word>runtime</Word>
<Word>method</Word>
<Word>field</Word>
<Word>bytearray</Word>
<Word>final</Word>
<Word>sealed</Word>
<Word>specialname</Word>
<Word>family</Word>
<Word>assembly</Word>
<Word>famandassem</Word>
<Word>famorassem</Word>
<Word>privatescope</Word>
<Word>nested</Word>
<Word>hidebysig</Word>
<Word>newslot</Word>
<Word>rtspecialname</Word>
<Word>pinvokeimpl</Word>
<Word>unmanagedexp</Word>
<Word>reqsecobj</Word>
<Word>.ctor</Word>
<Word>.cctor</Word>
<Word>initonly</Word>
<Word>literal</Word>
<Word>notserialized</Word>
<Word>forwardref</Word>
<Word>internalcall</Word>
<Word>noinlining</Word>
<Word>aggressiveinlining</Word>
<Word>nomangle</Word>
<Word>lasterr</Word>
<Word>winapi</Word>
<Word>cdecl</Word>
<Word>stdcall</Word>
<Word>thiscall</Word>
<Word>fastcall</Word>
<Word>as</Word>
<Word>pinned</Word>
<Word>modreq</Word>
<Word>modopt</Word>
<Word>serializable</Word>
<Word>at</Word>
<Word>tls</Word>
<Word>true</Word>
<Word>false</Word>
<Word>strict</Word>
</Keywords>
<Keywords color="Directives">
<Word>.class</Word>
<Word>.namespace</Word>
<Word>.method</Word>
<Word>.field</Word>
<Word>.emitbyte</Word>
<Word>.try</Word>
<Word>.maxstack</Word>
<Word>.locals</Word>
<Word>.entrypoint</Word>
<Word>.zeroinit</Word>
<Word>.pdirect</Word>
<Word>.data</Word>
<Word>.event</Word>
<Word>.addon</Word>
<Word>.removeon</Word>
<Word>.fire</Word>
<Word>.other</Word>
<Word>protected</Word>
<Word>.property</Word>
<Word>.set</Word>
<Word>.get</Word>
<Word>default</Word>
<Word>.import</Word>
<Word>.permission</Word>
<Word>.permissionset</Word>
<Word>.line</Word>
<Word>.language</Word>
<Word>#line</Word>
</Keywords>
<Keywords color="Security">
<Word>request</Word>
<Word>demand</Word>
<Word>assert</Word>
<Word>deny</Word>
<Word>permitonly</Word>
<Word>linkcheck</Word>
<Word>inheritcheck</Word>
<Word>reqmin</Word>
<Word>reqopt</Word>
<Word>reqrefuse</Word>
<Word>prejitgrant</Word>
<Word>prejitdeny</Word>
<Word>noncasdemand</Word>
<Word>noncaslinkdemand</Word>
<Word>noncasinheritance</Word>
</Keywords>
<Keywords color="Directives">
<!-- custom value specifier -->
<Word>.custom</Word>
<!-- IL method attribute -->
<Word>init</Word>
<!-- Class layout directives -->
<Word>.size</Word>
<Word>.pack</Word>
<!-- Manifest-related keywords -->
<Word>.file</Word>
<Word>nometadata</Word>
<Word>.hash</Word>
<Word>.assembly</Word>
<Word>implicitcom</Word>
<Word>noappdomain</Word>
<Word>noprocess</Word>
<Word>nomachine</Word>
<Word>.publickey</Word>
<Word>.publickeytoken</Word>
<Word>algorithm</Word>
<Word>.ver</Word>
<Word>.locale</Word>
<Word>extern</Word>
<Word>.export</Word>
<Word>.manifestres</Word>
<Word>.mresource</Word>
<Word>.localized</Word>
<!-- Field marshaling keywords -->
<Word>.module</Word>
<Word>marshal</Word>
<Word>custom</Word>
<Word>sysstring</Word>
<Word>fixed</Word>
<Word>variant</Word>
<Word>currency</Word>
<Word>syschar</Word>
<Word>decimal</Word>
<Word>date</Word>
<Word>bstr</Word>
<Word>tbstr</Word>
<Word>lpstr</Word>
<Word>lpwstr</Word>
<Word>lptstr</Word>
<Word>objectref</Word>
<Word>iunknown</Word>
<Word>idispatch</Word>
<Word>struct</Word>
<Word>safearray</Word>
<Word>byvalstr</Word>
<Word>lpvoid</Word>
<Word>any</Word>
<Word>array</Word>
<Word>lpstruct</Word>
<!-- VTable fixup keywords -->
<Word>.vtfixup</Word>
<Word>fromunmanaged</Word>
<Word>callmostderived</Word>
<Word>.vtentry</Word>
<!-- Parameter attributes -->
<Word>in</Word>
<Word>out</Word>
<Word>opt</Word>
<Word>lcid</Word>
<Word>retval</Word>
<Word>.param</Word>
<!-- Method implementations -->
<Word>.override</Word>
<Word>with</Word>
<!-- VariantType keywords -->
<Word>null</Word>
<Word>error</Word>
<Word>hresult</Word>
<Word>carray</Word>
<Word>userdefined</Word>
<Word>record</Word>
<Word>filetime</Word>
<Word>blob</Word>
<Word>stream</Word>
<Word>storage</Word>
<Word>streamed_object</Word>
<Word>stored_object</Word>
<Word>blob_object</Word>
<Word>cf</Word>
<Word>clsid</Word>
<Word>vector</Word>
<!-- Null reference keyword for InitOpt -->
<Word>nullref</Word>
<!-- Header flags keywords -->
<Word>.subsystem</Word>
<Word>.corflags</Word>
<Word>.stackreserve</Word>
<Word>alignment</Word>
<Word>.imagebase</Word>
</Keywords>
<Span color="Comment" ruleSet="CommentMarkerSet">
<Begin>//</Begin>
</Span>
<Span color="Comment" ruleSet="CommentMarkerSet">
<Begin>/\*</Begin>
<End>\*/</End>
</Span>
<Span color="String">
<Begin>"</Begin>
<End>"</End>
</Span>
</RuleSet>
<RuleSet name="CommentMarkerSet" ignoreCase="false">
<Keywords foreground="#FFFF0000" fontWeight="bold">
<Word>TODO</Word>
<Word>FIXME</Word>
</Keywords>
<Keywords foreground="#EEE0E000" fontWeight="bold">
<Word>HACK</Word>
<Word>UNDONE</Word>
</Keywords>
</RuleSet>
</SyntaxDefinition>

63
ILSpy/TextView/XML-Mode-Dark.xshd

@ -1,63 +0,0 @@ @@ -1,63 +0,0 @@
<SyntaxDefinition name="XML" extensions=".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.booproj;.build;.xfrm;.targets;.xaml;.xpt;.xft;.map;.wsdl;.disco;.ps1xml;.nuspec" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color foreground="Green" name="Comment" exampleText="&lt;!-- comment --&gt;" />
<Color foreground="#FFD69D85" name="CData" exampleText="&lt;![CDATA[data]]&gt;" />
<Color foreground="#FFD69D85" name="DocType" exampleText="&lt;!DOCTYPE rootElement&gt;" />
<Color foreground="#FFD69D85" name="XmlDeclaration" exampleText='&lt;?xml version="1.0"?&gt;' />
<Color foreground="#FFD69D85" name="XmlTag" exampleText='&lt;tag attribute="value" /&gt;' />
<Color foreground="#FF00A0FF" name="AttributeName" exampleText='&lt;tag attribute="value" /&gt;' />
<Color foreground="#FFD69D85" name="AttributeValue" exampleText='&lt;tag attribute="value" /&gt;' />
<Color foreground="#FFd8a0df" name="Entity" exampleText="index.aspx?a=1&amp;amp;b=2" />
<Color foreground="#FF559CD6" name="BrokenEntity" exampleText="index.aspx?a=1&amp;b=2" />
<RuleSet>
<Span color="Comment" multiline="true">
<Begin>&lt;!--</Begin>
<End>--&gt;</End>
</Span>
<Span color="CData" multiline="true">
<Begin>&lt;!\[CDATA\[</Begin>
<End>]]&gt;</End>
</Span>
<Span color="DocType" multiline="true">
<Begin>&lt;!DOCTYPE</Begin>
<End>&gt;</End>
</Span>
<Span color="XmlDeclaration" multiline="true">
<Begin>&lt;\?</Begin>
<End>\?&gt;</End>
</Span>
<Span color="XmlTag" multiline="true">
<Begin>&lt;</Begin>
<End>&gt;</End>
<RuleSet>
<!-- Treat the position before '<' as end, as that's not a valid character
in attribute names and indicates the user forgot a closing quote. -->
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
<Begin>"</Begin>
<End>"|(?=&lt;)</End>
</Span>
<Span color="AttributeValue" multiline="true" ruleSet="EntitySet">
<Begin>'</Begin>
<End>'|(?=&lt;)</End>
</Span>
<Rule color="AttributeName">[\d\w_\-\.]+(?=(\s*=))</Rule>
<Rule color="AttributeValue">=</Rule>
</RuleSet>
</Span>
<Import ruleSet="EntitySet"/>
</RuleSet>
<RuleSet name="EntitySet">
<Rule color="Entity">
&amp;
[\w\d\#]+
;
</Rule>
<Rule color="BrokenEntity">
&amp;
[\w\d\#]*
#missing ;
</Rule>
</RuleSet>
</SyntaxDefinition>

69
ILSpy/Themes/DarkTheme.xaml

@ -65,4 +65,73 @@ @@ -65,4 +65,73 @@
<styles:InvertGrayEffect x:Key="{x:Static themes:ResourceKeys.ThemeAwareButtonEffect}" />
<!-- ILAsm -->
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Comment" Foreground="#FF57A64A" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.String" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Instructions" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Keywords" Foreground="#FFD69D85" FontWeight="Bold" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Directives" Foreground="#FF57A64A" FontWeight="Bold" />
<themes:SyntaxColor x:Key="SyntaxColor.ILAsm.Security" Foreground="#FF559CD6" />
<!-- Asm -->
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Comment" Foreground="#FF57A64A" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.NumberLiteral" Foreground="Orange" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.String" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Instructions" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Math Instructions" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Extended Instructions" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Registers" Foreground="#8080FF" Background="#EEEEEE" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Directives" Foreground="#FFD69D85" FontWeight="Bold" />
<themes:SyntaxColor x:Key="SyntaxColor.Asm.Directive Operands" Foreground="#FFb5cea8" FontWeight="Bold" />
<!-- CSharp -->
<themes:SyntaxColor x:Key="SyntaxColor.C#.Comment" Foreground="#FF57A64A" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.String" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.StringInterpolation" Foreground="#FFffd68f" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Char" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Preprocessor" Foreground="#FF9B9B9B" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Punctuation" Foreground="White" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ValueTypeKeywords" Foreground="#FF00A0FF" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ReferenceTypeKeywords" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.NumberLiteral" Foreground="#FFb5cea8" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ThisOrBaseReference" Foreground="#FF3a6a9b" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.NullOrValueKeywords" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Keywords" Foreground="#FFd8a0df" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.GotoKeywords" Foreground="#FFd8a0df" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.QueryKeywords" Foreground="#FFd8a0df" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ExceptionKeywords" Foreground="#FFd8a0df" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.CheckedKeyword" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.UnsafeKeywords" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.OperatorKeywords" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ParameterModifiers" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Modifiers" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.Visibility" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.NamespaceKeywords" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.GetSetAddRemove" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.TrueFalse" Foreground="#FF00A0FF" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.TypeKeywords" Foreground="#FF559CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.AttributeKeywords" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ReferenceTypes" Foreground="#569CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.InterfaceTypes" Foreground="#569CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.TypeParameters" Foreground="#569CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.DelegateTypes" Foreground="#569CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.ValueTypes" FontWeight="Bold" Foreground="#569CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.EnumTypes" FontWeight="Bold" Foreground="#569CD6" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.MethodCall" Foreground="#FFdcdcaa" FontWeight="Bold" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.FieldAccess" FontStyle="Italic" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.InactiveCode" Foreground="Gray" />
<themes:SyntaxColor x:Key="SyntaxColor.C#.SemanticError" Foreground="DarkRed" />
<!-- XML -->
<themes:SyntaxColor x:Key="SyntaxColor.XML.Comment" Foreground="Green" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.CData" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.DocType" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.XmlDeclaration" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.XmlTag" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.AttributeName" Foreground="#FF00A0FF" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.AttributeValue" Foreground="#FFD69D85" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.Entity" Foreground="#FFd8a0df" />
<themes:SyntaxColor x:Key="SyntaxColor.XML.BrokenEntity" Foreground="#FF559CD6" />
</ResourceDictionary>

31
ILSpy/Themes/SyntaxColor.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
#nullable enable
using System.Windows;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Highlighting;
namespace ICSharpCode.ILSpy.Themes;
public class SyntaxColor
{
public Color? Foreground { get; set; }
public Color? Background { get; set; }
public FontWeight? FontWeight { get; set; }
public FontStyle? FontStyle { get; set; }
public void ApplyTo(HighlightingColor color)
{
if (Foreground is { } foreground)
color.Foreground = new SimpleHighlightingBrush(foreground);
if (Background is { } background)
color.Background = new SimpleHighlightingBrush(background);
if (FontWeight is { } fontWeight)
color.FontWeight = fontWeight;
if (FontStyle is { } fontStyle)
color.FontStyle = fontStyle;
}
}

52
ILSpy/Themes/ThemeManager.cs

@ -16,20 +16,25 @@ @@ -16,20 +16,25 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#nullable enable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.AvalonEdit.Highlighting;
namespace ICSharpCode.ILSpy.Themes
{
public class ThemeManager
{
private static List<string> _allThemes;
private string _theme;
private readonly ResourceDictionary _themeDictionaryContainer = new ResourceDictionary();
private string? _theme;
private readonly ResourceDictionary _themeDictionaryContainer = new();
private readonly Dictionary<string, SyntaxColor> _syntaxColors = new();
public static readonly ThemeManager Current = new ThemeManager();
public static readonly ThemeManager Current = new();
private ThemeManager()
{
@ -40,12 +45,10 @@ namespace ICSharpCode.ILSpy.Themes @@ -40,12 +45,10 @@ namespace ICSharpCode.ILSpy.Themes
public static IReadOnlyCollection<string> AllThemes => new[] { "Light", "Dark" };
public string Theme {
get => _theme;
get => _theme ?? DefaultTheme;
set {
_theme = value;
_themeDictionaryContainer.MergedDictionaries.Clear();
_themeDictionaryContainer.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"themes/{value}Theme.xaml", UriKind.Relative) });
UpdateTheme();
}
}
@ -65,5 +68,38 @@ namespace ICSharpCode.ILSpy.Themes @@ -65,5 +68,38 @@ namespace ICSharpCode.ILSpy.Themes
{
return new Style(typeof(Button), (Style)Application.Current.FindResource(ToolBar.ButtonStyleKey));
}
public void UpdateColors(IHighlightingDefinition highlightingDefinition)
{
var prefix = $"SyntaxColor.{highlightingDefinition.Name}.";
foreach (var (key, syntaxColor) in _syntaxColors)
{
var color = highlightingDefinition.GetNamedColor(key.Substring(prefix.Length));
if (color is not null)
syntaxColor.ApplyTo(color);
}
}
private void UpdateTheme()
{
_themeDictionaryContainer.MergedDictionaries.Clear();
_themeDictionaryContainer.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"themes/{Theme}Theme.xaml", UriKind.Relative) });
_syntaxColors.Clear();
ProcessDictionary(_themeDictionaryContainer);
void ProcessDictionary(ResourceDictionary resourceDictionary)
{
foreach (DictionaryEntry entry in resourceDictionary)
{
if (entry is { Key: string key, Value: SyntaxColor syntaxColor })
_syntaxColors.TryAdd(key, syntaxColor);
}
foreach (ResourceDictionary mergedDictionary in resourceDictionary.MergedDictionaries)
ProcessDictionary(mergedDictionary);
}
}
}
}

Loading…
Cancel
Save