Skip to content

Instantly share code, notes, and snippets.

@dfkeenan
dfkeenan / RefInFix.cs
Last active October 19, 2024 14:12
Console application for fixing C# warning CS9192: Argument should be passed with ref or in
using Microsoft.CodeAnalysis.MSBuild;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editing;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
using Microsoft.CodeAnalysis.CSharp;
var solutionFilePath = @"SomeSolution.sln";
using var workspace = MSBuildWorkspace.Create();
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>AvaloniaUIDirectProperty</Title>
<Author>
</Author>
@dfkeenan
dfkeenan / Program.cs
Last active January 27, 2021 16:57
Transform VS Image Library icons for themes
using System;
using System.Xml.Linq;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using SkiaSharp;
namespace VSIMageLib
{
class Program
@dfkeenan
dfkeenan / Directory.Build.targets
Last active May 21, 2020 21:41
Xenko Move to Lib
<Project>
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="MoveLib" AfterTargets="AfterBuild">
<ItemGroup>
<LibFiles Include="$(OutDir)*.*" Exclude="$(OutDir)$(AssemblyName).*" />
</ItemGroup>
<Move SourceFiles="@(LibFiles)" DestinationFolder="$(OutDir)lib" />
<TransformXml Source="$(OutDir)$(AssemblyName).exe.config" Transform="$(MSBuildThisFileDirectory)\LibTransform.xml" Destination="$(OutDir)$(AssemblyName).exe.config" />
</Target>
</Project>
@dfkeenan
dfkeenan / LazyContent.cs
Created March 2, 2019 08:24
LazyContent proof of concept
using System;
using System.Collections.Generic;
using System.Text;
using Xenko.Core;
using Xenko.Core.Annotations;
using Xenko.Core.Serialization;
using Xenko.Core.Serialization.Contents;
namespace MyGame
{

Create Icon

  magick convert logo.png -define icon:auto-resize=64,48,32,16 logo.ico
@dfkeenan
dfkeenan / Git Cheat Sheet.md
Last active October 5, 2019 03:54
Git Cheat Sheet

Git Cheat Sheet

Update Repository From Upstream

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

@dfkeenan
dfkeenan / NextSceneScript.cs
Created January 12, 2017 11:42
Xenko: Transitions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using PhysicsSample.Transitions.Rendering.Images;
using SiliconStudio.Core.Extensions;
using SiliconStudio.Core.Mathematics;
using SiliconStudio.Xenko.Engine;
using SiliconStudio.Xenko.Graphics;
using SiliconStudio.Xenko.Input;
@dfkeenan
dfkeenan / HowTo.md
Last active January 7, 2017 06:33
Xenko: How-To use Entity Framework + Sqlite (Windows)

How to use Entity Framework & Sqlite with Xenko

This is an example/how-to for using Entity Framework & Sqlite with Xenko

  1. Add EF references to the "project.json" file of the "MyGame.Game" portable library project. See attached.
  2. Restore NuGet packages.
  3. Add Nuget Packages "Microsoft.EntityFrameworkCore.Design" and "Microsoft.EntityFrameworkCore.Sqlite" to the "MyGame.Windows" project. (not sure why this is required, Asset Compiler errors otherwise).
  4. Create your own DbContext similar to example attached. The filename stuff is important.
  5. Create script to load your DbContext. See "MyDatabaseScript.cs".
  6. Add database file as a Raw Asset and mark as root so it is included in build.
@dfkeenan
dfkeenan / EntityExtensions.cs
Created December 22, 2016 12:40
Xenko Entity Extensions
using System.Collections.Generic;
using SiliconStudio.Xenko.Engine;
namespace MyGame
{
public static class EntityExtensions
{
public static IEnumerable<T> GetComponentsInChildren<T>(this Entity entity) where T : EntityComponent
{
//depth first