Skip to content

Instantly share code, notes, and snippets.

View jonpryor's full-sized avatar

Jonathan Pryor jonpryor

View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
var markers = new[]{
(a: 1, s: "a"),
using System;
using System.Threading;
using Mono.Unix;
using Mono.Unix.Native;
class Test {
static void Main ()
{
StartHandler();
Console.WriteLine("Press any key to exit...");

How would I do the equivalent of 'in_dir=s' => \@in_dirs from Perl's Getopt::Long, i.e., a case where --in_dir was used multiple times.

Manually, by capturing values in an intermediate list:

var dirs    = new List<string> ();
var options = new OptionSet {
    { "in_dir=", v => dirs.Add (v) },
};
var unmatched = options.Parse(new[]{

"--in_dir", "A",

Installation of Native Libraries

An Android .apk file can contain native libraries for one or more architectures. Historically, all native libraries for the target device are extracted at .apk installation time. This would result in two copies of native libraries on the target device: a set of native libraries which are stored compressed within the .apk, and a separate set of native libraries on the Android target filesystem.

Starting with Android v6.0 (API-23), Android added an ability for

This file has been truncated, but you can view the full file.
1>------ Skipped Build: Project: NativeLibrary, Configuration: Debug x86 ------
1>Project not selected to build for this solution configuration
2>Project 'Scratch.Gxa1704' is not up to date. Missing output file 'C:\Users\jopryo\source\repos\Scratch.Gxa1704\Scratch.Gxa1704\bin\Debug\Scratch.Gxa1704.dll'.
Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the NuGet Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
Running restore with 8 concurrent jobs.
Reading project file C:\Users\jopryo\source\repos\Scratch.Gxa1704\Scratch.Gxa1704\Scratch.Gxa1704.csproj.
Restoring packages for C:\Users\jopryo\source\repos\Scratch.Gxa1704\Scratch.Gxa1704\Scratch.Gxa1704.csproj...
Restoring packages for MonoAndroid,Version=v8.1...
Resolving conflicts for MonoAndroid,Version=v8.1...
// switch on type?
using System;
class App {
public static void Main ()
{
sbyte v;
if (TryConvert (42.0, out v)) {
Console.WriteLine ($"v={v}");
}
<api
api-source="class-parse">
<package
name="android.support.v7.recyclerview.extensions"
jni-name="android/support/v7/recyclerview/extensions">
<class
abstract="false"
deprecated="not deprecated"
jni-extends="Ljava/lang/Object;"
extends="java.lang.Object"

Binding Java 8 Interfaces from C♯

Help wanted! :-)

Background

Xamarin.Android binds the Android Java API, which means that all Java language features need to be "bound" to corresponding C# language features. For many language constructs, this binding is simple, e.g. type names are (usually) unchanged and identical, while other language features are changed in subtle

// Build with: csc curl.cs -r:System.Net.Http.dll /langversion:7.1
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using TTask = System.Threading.Tasks.Task;
class App {