Skip to content

Instantly share code, notes, and snippets.

View kant2002's full-sized avatar

Andrii Kurdiumov kant2002

View GitHub Profile
@kant2002
kant2002 / IMallocSpy.cs
Last active April 23, 2021 10:46
COM in NativeAOT
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("0000001d-0000-0000-C000-000000000046")]
public interface IMallocSpy
{
[PreserveSig]
uint PreAlloc(uint cbRequest);
[PreserveSig]
void* PostAlloc(void* pActual);
[PreserveSig]
@kant2002
kant2002 / dgml2dot.py
Created May 17, 2021 18:20
DGML to Dot file conversion for NativeAOT analysis
#!/usr/bin/env python3
import re
import sys
import xml.etree.ElementTree as ET
###########################################
def to_dot(fd):
'''TODO
'''
@kant2002
kant2002 / Interop.OleCreatePictureIndirect.cs
Last active March 25, 2023 18:39
WinForms and NativeAOT
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Ole32
@kant2002
kant2002 / GdipCreateBitmapFromStream.cs
Last active June 4, 2021 08:43
System.Drawing and NativeAOT
[DllImport("gdiplus.dll", ExactSpelling = true)]
internal static extern int GdipCreateBitmapFromStream(IStream stream, out IntPtr bitmap);
@kant2002
kant2002 / BasicComWrappers.cs
Last active June 18, 2021 14:26
DirectX and NativeAOT
unsafe partial class DirectXComWrappers : ComWrappers
{
protected override unsafe ComInterfaceEntry* ComputeVtables(object obj, CreateComInterfaceFlags flags, out int count)
{
throw new NotImplementedException();
}
protected override object CreateObject(IntPtr externalComObject, CreateObjectFlags flags)
{
return new UniversalWrapper(externalComObject);
@kant2002
kant2002 / Dockerfile
Created July 4, 2021 07:52
NativeAOTDocker
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine AS build
WORKDIR /app
COPY HelloWorldStatic.csproj .
COPY nuget.config .
RUN dotnet restore --runtime linux-musl-x64 HelloWorldStatic.csproj
RUN apk add clang libexecinfo binutils musl-dev build-base zlib-static
COPY . .
RUN dotnet publish -c Release -r linux-musl-x64 -o out HelloWorldStatic.csproj
@kant2002
kant2002 / paket.dependencies
Last active July 29, 2021 19:08
F# and NativeAOT
source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json
nuget Microsoft.DotNet.ILCompiler ~> 6.0.0-rc.1
@kant2002
kant2002 / conversation.md
Last active September 15, 2021 04:30
Tanner Gooding vs SingleAccretion

[6:31] SingleAccretion: (Completely unrelated)

Let's test my API design ability. What is the difference between SetHWIntrinsic and ChangeHWIntrinsic?

[6:33] Tanner Gooding: I would assume Change might do other transformations required if they aren't directly compatible or something

I don't particularly like the name 😄

[6:37] SingleAccretion: (Alternatives are very welcome of course)

@kant2002
kant2002 / rd.xml
Created November 20, 2021 03:44
RTSP and NativeAOT
<?xml version="1.0" encoding="utf-8" ?>
<Directives>
<Application>
<Assembly Name="Microsoft.AspNetCore.Mvc.Razor">
<Type Name="Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFactory" Dynamic="Required All" />
</Assembly>
<Assembly Name="Microsoft.AspNetCore.Mvc.Core" Dynamic="Required All">
<Type Name="Microsoft.Extensions.Internal.PropertyHelper">
<Method Name="CallNullSafePropertyGetter" Dynamic="Required">
<GenericArgument Name="VideoMonitoring.Pages.ErrorModel, VideoMonitoring" />
@kant2002
kant2002 / Discussion.md
Created December 20, 2021 12:29
Jit in C# discussion

MS: Michal Strehovlky AK: Andrii Kurdiumov

MS: yeah well there's still some things that can only be done in C/C++ and cannot be done in C#

AK: I understand that life not all rosy. but when I see how you bend C# to your wishes, I think a lot of can be done.

I trying to build standalone Jit without relying on infrastructure too much to be able mix a bit of C#, but so far it's hard.