This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
bool b = false; | |
short s = 0; | |
var res = b ? 1L : s; | |
Console.WriteLine(res.GetType()); // prints Int64 | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Uses ICSharpCode.NRefactory 5.2 | |
using System; | |
using System.Linq; | |
using ICSharpCode.NRefactory.CSharp; | |
using ICSharpCode.NRefactory.PatternMatching; | |
namespace DecompileQueries | |
{ | |
class Program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
using System.Threading; | |
[CompilerGenerated] | |
[StructLayout(LayoutKind.Auto)] | |
private struct <CopyToAsyncInternal>d__2 : IAsyncStateMachine | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original: | |
public async Task<bool> SimpleBoolTaskMethod() | |
{ | |
Console.WriteLine("Before"); | |
await Task.Delay(TimeSpan.FromSeconds(1.0)); | |
Console.WriteLine("After"); | |
return true; | |
} | |
// MoveNext |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void AddLayer(ScrollViewer scrollViewer) | |
{ | |
scrollViewer.ApplyTemplate(); | |
ScrollBar scrollBar = (ScrollBar)scrollViewer.Template.FindName("PART_VerticalScrollBar", scrollViewer); | |
scrollBar.ApplyTemplate(); | |
Track track = (Track)scrollBar.Template.FindName("PART_Track", scrollBar); | |
var grid = VisualTreeHelper.GetParent(track) as Grid; | |
if (grid != null) { | |
var myElement = new Border(); | |
Grid.SetColumn(myElement, Grid.GetColumn(track)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2012 Daniel Grunwald | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this | |
// software and associated documentation files (the "Software"), to deal in the Software | |
// without restriction, including without limitation the rights to use, copy, modify, merge, | |
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons | |
// to whom the Software is furnished to do so, subject to the following conditions: | |
// | |
// The above copyright notice and this permission notice shall be included in all copies or | |
// substantial portions of the Software. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class WpfExtensions | |
{ | |
public static DispatcherAwaiter GetAwaiter(this Dispatcher dispatcher) | |
{ | |
return new DispatcherAwaiter(dispatcher, DispatcherPriority.Normal); | |
} | |
public static Tuple<Dispatcher, DispatcherPriority> WithPriority(this Dispatcher dispatcher, DispatcherPriority priority) | |
{ | |
return Tuple.Create(dispatcher, priority); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IType Resolve(ITypeResolveContext context) | |
{ | |
string[] parts = typeName.Split('.'); | |
var assemblies = new [] { context.CurrentAssembly, context.Compilation.MainAssembly }.Concat(context.Compilation.ReferencedAssemblies); | |
for (int i = parts.Length - 1; i >= 0; i++) { | |
string ns = string.Join(".", parts, 0, i); | |
string name = parts[i]; | |
int topLevelTPC = (i == parts.Length - 1 ? typeParameterCount : 0); | |
foreach (var asm in assemblies) { | |
if (asm == null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Xml; | |
using System.Xml.Linq; | |
using ICSharpCode.NRefactory.TypeSystem; | |
using ICSharpCode.NRefactory.TypeSystem.Implementation; | |
namespace TestNRMemoryUsage | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var usingVarDecl = new VariableDeclarationStatement { | |
Type = Pattern.Any("type"), | |
Variables = { | |
Pattern.NamedGroup( | |
"variable", | |
new VariableInitializer { | |
Initializer = Pattern.Any() | |
} | |
) | |
} |
NewerOlder