Skip to content

Instantly share code, notes, and snippets.

@citizenmatt
citizenmatt / tests.js
Created April 7, 2014 10:46
Angular tests with beforeEach and inject
/// <reference path="angular.js"/>
/// <reference path="angular-mocks.js"/>
/// <reference path="~/app/myApp.js"/>
describe("The moviesCtrl", function () {
'use strict';
// this is useful - will cause the browser running the tests for ReSharper
// to pause in the debugger, then using the normal dev tools, see what
// scripts are loaded, and (importantly) in what order
@citizenmatt
citizenmatt / test_with_settings.cs
Created April 15, 2014 22:07
ReSharper test with settings
[Test]
public void TestSomething()
{
Lifetimes.Using(lifetime => {
// Defined in BaseTest. Injects a writable storage at high priority
// to accept changes to settings, and which is thrown away when the
// lifetime terminates
ChangeSettingsTemporarily(lifetime);
var settingsStore = ShellInstance.GetComponent<ISettingsStore>().BindToContextLive(lifetime, ContextRange.ApplicationWide);
@citizenmatt
citizenmatt / SimpleCacheBase.cs
Created June 16, 2014 09:01
Simple abstract base class to provide a boilerplate implemention of ReSharper's ICache
using System.Collections.Generic;
using System.IO;
using System.Linq;
using JetBrains.Application;
using JetBrains.Application.Progress;
using JetBrains.DocumentManagers.impl;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Caches;
using JetBrains.ReSharper.Psi.Tree;

Running ReSharper in Visual Studio Experimental Instance

Visual Studio's "Experimental Instance" feature is intended for developing and debugging Visual Studio extensions, and maintains a separate copy of the configuration needed to run Visual Studio. Each experimental instance can have an entirely different configuration, from theme and window layout to the extensions that are loaded.

Note "Experimental instances" were previously known as "custom hives"

By default, ReSharper (and the other .net tools, dotCover, dotMemory, dotTrace, etc.) are installed as per-machine Visual Studio extensions. This means that they are available to all users on the machine, but also that they are loaded in all experimental instances.

The Platform layer that provides Visual Studio integration to ReSharper and the other .net tools, has support to move its registration from per-machine to per-user, and per-experimental instance. This allows for ReSharper (dotTrace

@citizenmatt
citizenmatt / XmlPsiManipulation.md
Last active August 29, 2015 14:05
Scratch docs for manipulating the XML PSI

Manipulating the Tree

The XML PSI tree doesn't provide many strongly typed methods for manipulating the tree. The IXmlTag and IXmlTagContainer nodes are the only ones that provide methods.

public inteface IXmlTag
{
  // ...snip...

 TXmlAttribute AddAttributeAfter(TXmlAttribute attribute, IXmlAttribute anchor);
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>SpecsFor.Templates</id>
<title>SpecsFor File &amp; Live Templates</title>
<version>2.0.0</version>
<authors>Matt Honeycutt</authors>
<owners>Matt Honeycutt</owners>
<licenseUrl>https://github.com/MattHoneycutt/SpecsFor/blob/master/LICENSE.md</licenseUrl>
<projectUrl>http://specsfor.com/</projectUrl>
@citizenmatt
citizenmatt / corefx_build.log
Created February 5, 2015 09:29
Console output when running build.cmd for dotnet/corefx
Restoring build tools...
Restoring all package dependencies...
Restoring all package dependencies...
C:\Users\matt\Code\forks\GitHub\dotnet\corefx\packages\Microsoft.DotNet.BuildTools.1.0.22-prerelease\lib\packageresolve.targets(25,5): warning : Unable to resolve the assets of System.Runtime: Couldn't find a matching group [C:\Users\matt\Code\forks\GitHub\dotnet\corefx\src\Microsoft.Win32.Primitives\src\Microsoft.Win32.Primitives.csproj]
C:\Users\matt\Code\forks\GitHub\dotnet\corefx\packages\Microsoft.DotNet.BuildTools.1.0.22-prerelease\lib\packageresolve.targets(25,5): warning : Unable to resolve the assets of System.Runtime.InteropServices: Couldn't find a matching group [C:\Users\matt\Code\forks\GitHub\dotnet\corefx\src\Microsoft.Win32.Primitives\src\Microsoft.Win32.Primitives.csproj]
C:\Users\matt\Code\forks\GitHub\dotnet\corefx\packages\Microsoft.DotNet.BuildTools.1.0.22-prerelease\lib\packageresolve.targets(25,5): warning : Unable to resolve the assets of System.Resources.ResourceManager: Couldn't
@citizenmatt
citizenmatt / AccountController.cs
Created September 16, 2011 15:37
Spark using ThemeDescriptorFilter
public ActionResult Blah()
{
return View();
}
@citizenmatt
citizenmatt / AssemblyInfo.cs
Created August 21, 2012 15:03
ReSharper plugin example to intercept enter key presses in a C# file
using System.Reflection;
using JetBrains.ActionManagement;
using JetBrains.Application.PluginSupport;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TypingAssistManagerTest")]
[assembly: AssemblyDescription("Example of how to hook into typing assist handler chain")]
[assembly: AssemblyConfiguration("")]
@citizenmatt
citizenmatt / gist:5857410
Last active December 18, 2015 22:49
ReSharper Live Template to create class with underscores in name

Edit the "Class" File Template (ReSharper -> Templates Explorer -> File Template -> C# -> Class) to be this:

$HEADER$namespace $NAMESPACE$
{
  $SELSTART$// File: $FILENAME$.cs$SELEND$
  public class $CLASS$ {}
}