Skip to content

Instantly share code, notes, and snippets.

@michaeldimoudis
Created August 24, 2017 22:24
Show Gist options
  • Save michaeldimoudis/783a526d7d7bb01c9fcaaaff5ec21ca6 to your computer and use it in GitHub Desktop.
Save michaeldimoudis/783a526d7d7bb01c9fcaaaff5ec21ca6 to your computer and use it in GitHub Desktop.
.Net Core Func<T, T, T, T, T, T, T, T, TR> bug on unix environments? Works in Windows. Bug exists in core 1.1 & 2.0
using System;
namespace functest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Func<int, Guid, Guid, string, int, string, DateTimeOffset, string, bool> goodFunc = GoodFunc;
Func<string, int, Guid, Guid, string, int, string, DateTimeOffset, bool> badFunc = BadFunc;
Console.WriteLine($"Test Good Func: {goodFunc(1, Guid.NewGuid(), Guid.NewGuid(), "four", 5, "six", DateTimeOffset.UtcNow, "eight")}");
Console.WriteLine($"Test Bad Func: {badFunc("one", 2, Guid.NewGuid(), Guid.NewGuid(), "five", 6, "seven", DateTimeOffset.UtcNow)}");
Console.ReadLine();
}
private static bool GoodFunc(int one, Guid two, Guid three, string four, int five, string six, DateTimeOffset seven, string eight)
{
Console.WriteLine($"one: {one}");
Console.WriteLine($"two: {two}");
Console.WriteLine($"three: {three}");
Console.WriteLine($"four: {four}");
Console.WriteLine($"five: {five}");
Console.WriteLine($"six: {six}");
Console.WriteLine($"seven: {seven}");
Console.WriteLine($"eight: {eight}");
return true;
}
// Below works on a Windows box, crashes out on unix
private static bool BadFunc(string one, int two, Guid three, Guid four, string five, int six, string seven, DateTimeOffset eight)
{
Console.WriteLine($"one: {one}"); // On unix `one` is "five"
Console.WriteLine($"two: {two}");
Console.WriteLine($"three: {three}");
Console.WriteLine($"four: {four}");
Console.WriteLine($"five: {five}"); // On unix `five` has an error with 'Unable to read memory'
Console.WriteLine($"six: {six}");
Console.WriteLine($"seven: {seven}");
Console.WriteLine($"eight: {eight}");
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment