Skip to content

Instantly share code, notes, and snippets.

@DustinCampbell
DustinCampbell / using-msbuildworkspace.md
Created April 10, 2018 21:36
Using MSBuildWorkspace

Introduction

Roslyn provides a rich set of APIs for analyzing C# and Visual Basic source code, but constructing a context in which to perform analysis can be challenging. For simple tasks, creating a Compilation populated with SyntaxTrees, MetadataReferences and a handful of options may suffice. However, if there are multiple projects involved in the analysis, it is more complicated because multiple Compilations need to be created with references between them.

To simplify the construction process. Roslyn provides the Workspace API, which can be used to model solutions, projects and documents. The Workspace API performs all of the heavy lifting needed to parse SyntaxTrees from source code, load MetadataReferences, and construct Compilations and add references between them.

@WikkidEdd
WikkidEdd / CreateSymlinkProject.cs
Last active November 19, 2023 11:45
Creates a symlinked version of a Unity project so you can easily do network development. Add script to Editor folder. Run from "Utils/Create Symlink Project" then choose directory to put symlink'd project in.
using UnityEngine;
using UnityEditor;
using System.Diagnostics;
public class CreateSymlinkProject {
[MenuItem("Utils/Create Symlink Project")]
static void DoIt()
{
string folderName = EditorUtility.SaveFolderPanel("Symlink Project Location", "", "");
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active November 10, 2024 05:01
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@Lazersquid
Lazersquid / Reference.cs
Last active January 30, 2023 19:44
Unity generic scriptable object variable reference pattern
using System;
/// <summary>
/// Reference Class.
/// </summary>
[Serializable]
public abstract class Reference
{
}
@hiepxanh
hiepxanh / add-voice.ps
Created November 23, 2017 03:08
Add microsoft core voice to any application can use
$sourcePath = 'HKLM:\software\Microsoft\Speech_OneCore\Voices\Tokens' #Where the OneCore voices live
$destinationPath = 'HKLM:\SOFTWARE\Microsoft\Speech\Voices\Tokens' #For 64-bit apps
$destinationPath2 = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens' #For 32-bit apps
cd $destinationPath
$listVoices = Get-ChildItem $sourcePath
foreach($voice in $listVoices)
{
$source = $voice.PSPath #Get the path of this voices key
copy -Path $source -Destination $destinationPath -Recurse
copy -Path $source -Destination $destinationPath2 -Recurse
@RubenPineda
RubenPineda / DraggablePointAttribute.cs
Last active September 9, 2020 00:00
This is an updated version of ProGM's script. Now it handles Vector2, arrays and nested fields as well. You can also drag points locally. See the original code here: https://gist.github.com/ProGM/226204b2a7f99998d84d755ffa1fb39a. See also helper methods here: http://answers.unity3d.com/questions/425012/get-the-instance-the-serializedproperty-bel…
using UnityEngine;
public class DraggablePointAttribute : PropertyAttribute {
public bool local;
public DraggablePointAttribute (bool local = false) {
this.local = local;
}
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using System.IO;
using System.Reflection;
[InitializeOnLoad]
public static class ShowFileExtensions
{
@FreyaHolmer
FreyaHolmer / RigidbodyMassCalculator.cs
Created December 18, 2015 19:54
Used to approximate a proper mass value for all the colliders in a given Rigidbody
using UnityEngine;
using System.Linq;
[RequireComponent(typeof(Rigidbody))]
public class RigidbodyMassCalculator : MonoBehaviour {
public float density = 1f;
public bool recalculateOnAwake = true;
Rigidbody rb;
@aadnk
aadnk / SoundlessTeethlessExplosion.java
Created August 29, 2013 21:44
Create a soundless explosion that does no damage.
package com.comphenix.example;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@dolt131943
dolt131943 / download InfoQ Video
Created December 29, 2012 16:35
InfoQ的视频下载
http://union.bokecc.com/playvideo.bo?uid=C089D59BA5DEEC18&playerid=58C72EF83A565238&playertype=1&autoStart=false&vid=28535D5099D7FF35
http://union.bokecc.com/servlet/playinfo?uid=C089D59BA5DEEC18&vid=28535D5099D7FF35&lid=&pid=58C72EF83A565238&pt=1&m=1&t=2&pp=false&d=union.bokecc.com&fv=WIN%2011%2C5%2C502%2C110&uu=1432E6BE318DBAA44D95462F785FBEE3B4338501&rnd=4249
与上面等效可读取,从而匹配播放地址上的参数:
http://union.bokecc.com/servlet/playinfo?uid=C089D59BA5DEEC18&vid=28535D5099D7FF35&lid=&pid=58C72EF83A565238
<?xml version="1.0" encoding="UTF-8"?>