Skip to content

Instantly share code, notes, and snippets.

View mgnslndh's full-sized avatar

Magnus Lindhe mgnslndh

View GitHub Profile
@mgnslndh
mgnslndh / PointerTriggerBehavior.cs
Created August 18, 2023 14:23
This is an Avalonia behavior that lets you assign actions that will be executed when a pointer is pressed and/or released.
using Avalonia;
using Avalonia.Input;
using Avalonia.Xaml.Interactions.Events;
using Avalonia.Xaml.Interactivity;
namespace Avalonia.Xaml.Interactions
{
public class PointerTriggerBehavior : PointerEventsBehavior
{
/// <summary>
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Try.Try.Try
{
public abstract record Try<TSuccess, TFailure>
@mgnslndh
mgnslndh / Notes.md
Created January 13, 2022 08:14
NuGet Packaging

NuGet Packaging

Runtimes

When consuming a NuGet package with runtime libraries they will not be copied to the output directory if the consuming assembly is itself a library. It needs to be an executable.

Also note that class libraries don't have a host, hence don't have a RID. Therefore you may not see the runtime dlls. You need to make sure your test project that uses the package is something that has a host & entry point, like a console app.

Source.

<Project>
<Target Name="_DeleteFilesFromOutputDirectory" AfterTargets="CopyFilesToOutputDirectory">
<!-- Delete files that are not needed -->
<ItemGroup>
<!-- Satellite Assemblies -->
<FilesToDelete Include="$(OutDir)\**\*.resources.dll" />
</ItemGroup>
<Delete Files="@(FilesToDelete)" />
@mgnslndh
mgnslndh / BuildSecrets.targets
Created October 27, 2020 13:14
Build Secrets
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SomethingPropsDirectory>$(LOCALAPPDATA)\Something\</SomethingPropsDirectory>
<SomethingPropsFilePath>$(SomethingPropsDirectory)\Something.Build.props</SomethingPropsFilePath>
</PropertyGroup>
<Import Project="$(SomethingPropsFilePath)" Condition="Exists('$(SomethingPropsFilePath)')" />
<Target Name="GenerateBuildSecrets" BeforeTargets="CoreCompile">
public static class NibbleConverter
{
public static void GetNibbles(byte input, out byte lowNibble, out byte highNibble)
{
highNibble = (byte)(input >> 4 & 0xF);
lowNibble = (byte)(input & 0xF);
}
}
https://github.com/dotnet/sdk/issues/1151