Added Android Designer
|
@ -0,0 +1,23 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "DesignerTest", "DesignerTest\DesignerTest.fsproj", "{444D009C-7FF9-41A9-B92E-697A001F85C4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cs_test", "cs_test\cs_test.csproj", "{22BC1B43-F146-466A-8116-9972A2420EC4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{444D009C-7FF9-41A9-B92E-697A001F85C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{444D009C-7FF9-41A9-B92E-697A001F85C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{444D009C-7FF9-41A9-B92E-697A001F85C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{444D009C-7FF9-41A9-B92E-697A001F85C4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{22BC1B43-F146-466A-8116-9972A2420EC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{22BC1B43-F146-466A-8116-9972A2420EC4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{22BC1B43-F146-466A-8116-9972A2420EC4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{22BC1B43-F146-466A-8116-9972A2420EC4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,19 @@
|
|||
Any raw assets you want to be deployed with your application can be placed in
|
||||
this directory (and child directories) and given a Build Action of "AndroidAsset".
|
||||
|
||||
These files will be deployed with your package and will be accessible using Android's
|
||||
AssetManager, like this:
|
||||
|
||||
public class ReadAsset : Activity
|
||||
{
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
base.OnCreate (bundle);
|
||||
|
||||
InputStream input = Assets.Open ("my_asset.txt");
|
||||
}
|
||||
}
|
||||
|
||||
Additionally, some Android functions will automatically load asset files:
|
||||
|
||||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{444D009C-7FF9-41A9-B92E-697A001F85C4}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>DesignerTest</RootNamespace>
|
||||
<AssemblyName>DesignerTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidApplication>True</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.designer.fs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<PlatformTarget></PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
<GenerateTailCalls>true</GenerateTailCalls>
|
||||
<PlatformTarget></PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="FSharp.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="Java.Interop" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Runtime">
|
||||
<HintPath>..\..\..\..\..\..\Library\Frameworks\Xamarin.Android.framework\Versions\6.1.99-76\lib\xbuild-frameworks\MonoAndroid\v1.0\Facades\System.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.UIProvider.Runtime">
|
||||
<HintPath>..\..\bin\Debug\Xamarin.Android.UIProvider.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Resources\Resource.designer.fs" />
|
||||
<Compile Include="Properties\AssemblyInfo.fs" />
|
||||
<Compile Include="MainActivity.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="Properties\AndroidManifest.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\Main.axml" />
|
||||
<AndroidResource Include="Resources\values\Strings.xml" />
|
||||
<AndroidResource Include="Resources\mipmap-hdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-mdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xhdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxhdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxxhdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\layout\Test.axml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidAsset Include="Assets\AboutAssets.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.FSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,49 @@
|
|||
namespace DesignerTest
|
||||
|
||||
open System
|
||||
|
||||
open Android.App
|
||||
open Android.Content
|
||||
open Android.OS
|
||||
open Android.Runtime
|
||||
open Android.Views
|
||||
open Android.Widget
|
||||
open Xamarin.Android.UIProvider.Runtime
|
||||
|
||||
//type container1 = Xamarin.Android.FragmentUI<"Test.axml">
|
||||
type container2 = Xamarin.Android.ViewUI<"Test.axml">
|
||||
//type container3 = Xamarin.Android.ActivityUI<"Test.axml">
|
||||
|
||||
type MyView =
|
||||
inherit container2
|
||||
//new() as x = { inherit container2()} then x.Initialise()
|
||||
new(context) as x =
|
||||
{ inherit container2(context) } then x.Initialise()
|
||||
new(context:Context, attr:Android.Util.IAttributeSet) as x =
|
||||
{ inherit container2(context, attr) } then x.Initialise()
|
||||
|
||||
member x.Initialise() =
|
||||
let space1 = x.space1
|
||||
let tableLayout1 = x.tableLayout1
|
||||
tableLayout1.SetBackgroundColor Android.Graphics.Color.Tomato
|
||||
|
||||
[<Activity (Label = "DesignerTest", MainLauncher=true, Icon="@mipmap/icon")>]
|
||||
type MainActivity () =
|
||||
inherit Activity ()
|
||||
|
||||
let mutable count:int = 1
|
||||
|
||||
override this.OnCreate (bundle) =
|
||||
|
||||
base.OnCreate (bundle)
|
||||
|
||||
// Set our view from the "main" layout resource
|
||||
this.SetContentView (Resource_Layout.Main)
|
||||
|
||||
// Get our button from the layout resource, and attach an event to it
|
||||
let button = this.FindViewById<Button>(Resource_Id.myButton)
|
||||
button.Click.Add (fun args ->
|
||||
button.Text <- sprintf "%d clicks!" count
|
||||
count <- count + 1
|
||||
this.SetContentView(Resource_Layout.Test)
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.designertest">
|
||||
<uses-sdk android:minSdkVersion="20" />
|
||||
<application android:allowBackup="true" android:icon="@mipmap/icon" android:label="@string/app_name"></application>
|
||||
</manifest>
|
|
@ -0,0 +1,34 @@
|
|||
namespace DesignerTest
|
||||
module AssemblyInfo =
|
||||
|
||||
open System.Reflection
|
||||
open System.Runtime.CompilerServices
|
||||
open Android.App
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[<assembly: AssemblyTitle("DesignerTest")>]
|
||||
[<assembly: AssemblyDescription("")>]
|
||||
[<assembly: AssemblyConfiguration("")>]
|
||||
[<assembly: AssemblyCompany("")>]
|
||||
[<assembly: AssemblyProduct("")>]
|
||||
[<assembly: AssemblyCopyright("dave")>]
|
||||
[<assembly: AssemblyTrademark("")>]
|
||||
[<assembly: AssemblyCulture("")>]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[<assembly: AssemblyVersion("1.0.0")>]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[<assembly: AssemblyDelaySign(false)>]
|
||||
//[<assembly: AssemblyKeyFile("")>]
|
||||
|
||||
()
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
Images, layout descriptions, binary blobs and string dictionaries can be included
|
||||
in your application as resource files. Various Android APIs are designed to
|
||||
operate on the resource IDs instead of dealing with images, strings or binary blobs
|
||||
directly.
|
||||
|
||||
For example, a sample Android app that contains a user interface layout (main.axml),
|
||||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
|
||||
would keep its resources in the "Resources" directory of the application:
|
||||
|
||||
Resources/
|
||||
drawable/
|
||||
icon.png
|
||||
|
||||
layout/
|
||||
main.axml
|
||||
|
||||
values/
|
||||
strings.xml
|
||||
|
||||
In order to get the build system to recognize Android resources, set the build action to
|
||||
"AndroidResource". The native Android APIs do not operate directly with filenames, but
|
||||
instead operate on resource IDs. When you compile an Android application that uses resources,
|
||||
the build system will package the resources for distribution and generate a class called "R"
|
||||
(this is an Android convention) that contains the tokens for each one of the resources
|
||||
included. For example, for the above Resources layout, this is what the R class would expose:
|
||||
|
||||
public class R {
|
||||
public class drawable {
|
||||
public const int icon = 0x123;
|
||||
}
|
||||
|
||||
public class layout {
|
||||
public const int main = 0x456;
|
||||
}
|
||||
|
||||
public class strings {
|
||||
public const int first_string = 0xabc;
|
||||
public const int second_string = 0xbcd;
|
||||
}
|
||||
}
|
||||
|
||||
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
|
||||
to reference the layout/main.axml file, or R.strings.first_string to reference the first
|
||||
string in the dictionary file values/strings.xml.
|
|
@ -0,0 +1,121 @@
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version: 4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace global
|
||||
|
||||
[<assembly: Android.Runtime.ResourceDesignerAttribute("DesignerTest.Resource", IsApplication=true)>]
|
||||
do ()
|
||||
namespace DesignerTest
|
||||
// Generated by F# CodeDom
|
||||
#nowarn "49" // uppercase argument names
|
||||
#nowarn "67" // this type test or downcast will always hold
|
||||
#nowarn "66" // this upcast is unnecessary - the types are identical
|
||||
#nowarn "58" // possible incorrect indentation..
|
||||
#nowarn "57" // do not use create_DelegateEvent
|
||||
#nowarn "51" // address-of operator can occur in the code
|
||||
#nowarn "1183" // unused 'this' reference
|
||||
|
||||
exception ReturnException631d866fb09947dcabbec7f9fe5c92c0 of obj
|
||||
exception ReturnNoneException631d866fb09947dcabbec7f9fe5c92c0
|
||||
[<AutoOpen>]
|
||||
module FuncConvertFinalOverload631d866fb09947dcabbec7f9fe5c92c0 =
|
||||
// This extension member adds to the FuncConvert type and is the last resort member in the method overloading rules.
|
||||
type global.Microsoft.FSharp.Core.FuncConvert with
|
||||
/// A utility function to convert function values from tupled to curried form
|
||||
static member FuncFromTupled (f:'T -> 'Res) = f
|
||||
|
||||
type
|
||||
[<System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")>]
|
||||
|
||||
(* partial *)Resource () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
static member UpdateIdValues () =
|
||||
()
|
||||
|
||||
|
||||
|
||||
and
|
||||
|
||||
(* partial *)Resource_Attribute () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
|
||||
|
||||
|
||||
and
|
||||
|
||||
(* partial *)Resource_Id () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
// aapt resource value: 0x7f050004
|
||||
static member button1 = 2131034116
|
||||
|
||||
// aapt resource value: 0x7f050000
|
||||
static member myButton = 2131034112
|
||||
|
||||
// aapt resource value: 0x7f050006
|
||||
static member seekBar1 = 2131034118
|
||||
|
||||
// aapt resource value: 0x7f050001
|
||||
static member space1 = 2131034113
|
||||
|
||||
// aapt resource value: 0x7f050002
|
||||
static member tableLayout1 = 2131034114
|
||||
|
||||
// aapt resource value: 0x7f050003
|
||||
static member tableRow1 = 2131034115
|
||||
|
||||
// aapt resource value: 0x7f050005
|
||||
static member tableRow2 = 2131034117
|
||||
|
||||
// aapt resource value: 0x7f050007
|
||||
static member tableRow3 = 2131034119
|
||||
|
||||
// aapt resource value: 0x7f050008
|
||||
static member textView5 = 2131034120
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
|
||||
|
||||
|
||||
and
|
||||
|
||||
(* partial *)Resource_Layout () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
// aapt resource value: 0x7f030000
|
||||
static member Main = 2130903040
|
||||
|
||||
// aapt resource value: 0x7f030001
|
||||
static member Test = 2130903041
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
|
||||
|
||||
|
||||
and
|
||||
|
||||
(* partial *)Resource_Mipmap () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
// aapt resource value: 0x7f020000
|
||||
static member Icon = 2130837504
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
|
||||
|
||||
|
||||
and
|
||||
|
||||
(* partial *)Resource_String () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
// aapt resource value: 0x7f040001
|
||||
static member app_name = 2130968577
|
||||
|
||||
// aapt resource value: 0x7f040000
|
||||
static member hello = 2130968576
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<Button
|
||||
android:id="@+id/myButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hello" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="fdghjkl.Fragment1">
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/space1" />
|
||||
<TableLayout
|
||||
android:minWidth="25px"
|
||||
android:minHeight="25px"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tableLayout1">
|
||||
<TableRow
|
||||
android:id="@+id/tableRow1">
|
||||
<Button
|
||||
android:text="Button"
|
||||
android:layout_column="1"
|
||||
android:id="@+id/button1" />
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2">
|
||||
<SeekBar
|
||||
android:layout_column="1"
|
||||
android:id="@+id/seekBar1" />
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:id="@+id/tableRow3">
|
||||
<TextView
|
||||
android:text="Small Text"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_column="1"
|
||||
android:id="@+id/textView5" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
</LinearLayout>
|
Двоичные данные
src/Xamarin.Android.DesignerTest/DesignerTest/Resources/mipmap-hdpi/Icon.png
Normal file
После Ширина: | Высота: | Размер: 2.1 KiB |
Двоичные данные
src/Xamarin.Android.DesignerTest/DesignerTest/Resources/mipmap-mdpi/Icon.png
Normal file
После Ширина: | Высота: | Размер: 1.4 KiB |
Двоичные данные
src/Xamarin.Android.DesignerTest/DesignerTest/Resources/mipmap-xhdpi/Icon.png
Normal file
После Ширина: | Высота: | Размер: 3.2 KiB |
Двоичные данные
src/Xamarin.Android.DesignerTest/DesignerTest/Resources/mipmap-xxhdpi/Icon.png
Normal file
После Ширина: | Высота: | Размер: 5.3 KiB |
Двоичные данные
src/Xamarin.Android.DesignerTest/DesignerTest/Resources/mipmap-xxxhdpi/Icon.png
Normal file
После Ширина: | Высота: | Размер: 7.6 KiB |
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string
|
||||
name="hello">Hello World, Click Me!</string>
|
||||
<string
|
||||
name="app_name">DesignerTest</string>
|
||||
</resources>
|
|
@ -0,0 +1,19 @@
|
|||
Any raw assets you want to be deployed with your application can be placed in
|
||||
this directory (and child directories) and given a Build Action of "AndroidAsset".
|
||||
|
||||
These files will be deployed with your package and will be accessible using Android's
|
||||
AssetManager, like this:
|
||||
|
||||
public class ReadAsset : Activity
|
||||
{
|
||||
protected override void OnCreate (Bundle bundle)
|
||||
{
|
||||
base.OnCreate (bundle);
|
||||
|
||||
InputStream input = Assets.Open ("my_asset.txt");
|
||||
}
|
||||
}
|
||||
|
||||
Additionally, some Android functions will automatically load asset files:
|
||||
|
||||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
|
|
@ -0,0 +1,31 @@
|
|||
using Android.App;
|
||||
using Android.Widget;
|
||||
using Android.OS;
|
||||
|
||||
namespace cs_test
|
||||
{
|
||||
[Activity (Label = "cs_test", MainLauncher = true, Icon = "@mipmap/icon")]
|
||||
public class MainActivity : Activity
|
||||
{
|
||||
int count = 1;
|
||||
|
||||
protected override void OnCreate (Bundle savedInstanceState)
|
||||
{
|
||||
base.OnCreate (savedInstanceState);
|
||||
|
||||
// Set our view from the "main" layout resource
|
||||
SetContentView (Resource.Layout.Main);
|
||||
|
||||
// Get our button from the layout resource,
|
||||
// and attach an event to it
|
||||
Button button = FindViewById<Button> (Resource.Id.myButton);
|
||||
|
||||
button.Click += delegate { button.Text = string.Format ("{0} clicks!", count++);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
package="com.companyname.cs_test">
|
||||
<uses-sdk
|
||||
android:minSdkVersion="10" />
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/icon"
|
||||
android:label="@string/app_name">
|
||||
</application>
|
||||
</manifest>
|
|
@ -0,0 +1,28 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Android.App;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle ("cs_test")]
|
||||
[assembly: AssemblyDescription ("")]
|
||||
[assembly: AssemblyConfiguration ("")]
|
||||
[assembly: AssemblyCompany ("")]
|
||||
[assembly: AssemblyProduct ("")]
|
||||
[assembly: AssemblyCopyright ("dave")]
|
||||
[assembly: AssemblyTrademark ("")]
|
||||
[assembly: AssemblyCulture ("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion ("1.0.0")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
Images, layout descriptions, binary blobs and string dictionaries can be included
|
||||
in your application as resource files. Various Android APIs are designed to
|
||||
operate on the resource IDs instead of dealing with images, strings or binary blobs
|
||||
directly.
|
||||
|
||||
For example, a sample Android app that contains a user interface layout (main.axml),
|
||||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
|
||||
would keep its resources in the "Resources" directory of the application:
|
||||
|
||||
Resources/
|
||||
drawable/
|
||||
icon.png
|
||||
|
||||
layout/
|
||||
main.axml
|
||||
|
||||
values/
|
||||
strings.xml
|
||||
|
||||
In order to get the build system to recognize Android resources, set the build action to
|
||||
"AndroidResource". The native Android APIs do not operate directly with filenames, but
|
||||
instead operate on resource IDs. When you compile an Android application that uses resources,
|
||||
the build system will package the resources for distribution and generate a class called "R"
|
||||
(this is an Android convention) that contains the tokens for each one of the resources
|
||||
included. For example, for the above Resources layout, this is what the R class would expose:
|
||||
|
||||
public class R {
|
||||
public class drawable {
|
||||
public const int icon = 0x123;
|
||||
}
|
||||
|
||||
public class layout {
|
||||
public const int main = 0x456;
|
||||
}
|
||||
|
||||
public class strings {
|
||||
public const int first_string = 0xabc;
|
||||
public const int second_string = 0xbcd;
|
||||
}
|
||||
}
|
||||
|
||||
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
|
||||
to reference the layout/main.axml file, or R.strings.first_string to reference the first
|
||||
string in the dictionary file values/strings.xml.
|
4200
src/Xamarin.Android.DesignerTest/cs_test/Resources/Resource.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<Button
|
||||
android:id="@+id/myButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hello" />
|
||||
<cs_test.View23
|
||||
android:id="@+id/myView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="fdghjkl.Fragment1">
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/space1" />
|
||||
<TableLayout
|
||||
android:minWidth="25px"
|
||||
android:minHeight="25px"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/tableLayout1">
|
||||
<TableRow
|
||||
android:id="@+id/tableRow1">
|
||||
<Button
|
||||
android:text="Button"
|
||||
android:layout_column="1"
|
||||
android:id="@+id/button1" />
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:id="@+id/tableRow2">
|
||||
<SeekBar
|
||||
android:layout_column="1"
|
||||
android:id="@+id/seekBar1" />
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:id="@+id/tableRow3">
|
||||
<TextView
|
||||
android:text="Small Text"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:layout_column="1"
|
||||
android:id="@+id/textView5" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
</LinearLayout>
|
После Ширина: | Высота: | Размер: 2.1 KiB |
После Ширина: | Высота: | Размер: 1.4 KiB |
Двоичные данные
src/Xamarin.Android.DesignerTest/cs_test/Resources/mipmap-xhdpi/Icon.png
Normal file
После Ширина: | Высота: | Размер: 3.2 KiB |
Двоичные данные
src/Xamarin.Android.DesignerTest/cs_test/Resources/mipmap-xxhdpi/Icon.png
Normal file
После Ширина: | Высота: | Размер: 5.3 KiB |
Двоичные данные
src/Xamarin.Android.DesignerTest/cs_test/Resources/mipmap-xxxhdpi/Icon.png
Normal file
После Ширина: | Высота: | Размер: 7.6 KiB |
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string
|
||||
name="hello">Hello World, Click Me!</string>
|
||||
<string
|
||||
name="app_name">cs_test</string>
|
||||
</resources>
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Util;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
|
||||
namespace cs_test
|
||||
{
|
||||
//[Register ("com.companyname.cs_test.View23")]
|
||||
public class View23 : View
|
||||
{
|
||||
public View23 (Context context) :
|
||||
base (context)
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
public View23 (Context context, IAttributeSet attrs) :
|
||||
base (context, attrs)
|
||||
{
|
||||
Initialize ();
|
||||
}
|
||||
|
||||
//public View23 (Context context, IAttributeSet attrs, int defStyle) :
|
||||
// base (context, attrs, defStyle)
|
||||
//{
|
||||
// Initialize ();
|
||||
//}
|
||||
|
||||
void Initialize ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{22BC1B43-F146-466A-8116-9972A2420EC4}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>cs_test</RootNamespace>
|
||||
<AssemblyName>cs_test</AssemblyName>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidApplication>True</AndroidApplication>
|
||||
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="Xamarin.Android.Support.v4">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.v4.23.1.1.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xamarin.Android.Support.v7.AppCompat">
|
||||
<HintPath>..\packages\Xamarin.Android.Support.v7.AppCompat.23.1.1.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainActivity.cs" />
|
||||
<Compile Include="Resources\Resource.designer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="View23.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
<None Include="Properties\AndroidManifest.xml" />
|
||||
<None Include="Assets\AboutAssets.txt" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AndroidResource Include="Resources\layout\Main.axml" />
|
||||
<AndroidResource Include="Resources\values\Strings.xml" />
|
||||
<AndroidResource Include="Resources\mipmap-hdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-mdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xhdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxhdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\mipmap-xxxhdpi\Icon.png" />
|
||||
<AndroidResource Include="Resources\layout\Test.axml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\drawable\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Xamarin.Android.Support.v4" version="23.1.1.0" targetFramework="MonoAndroid60" />
|
||||
<package id="Xamarin.Android.Support.v7.AppCompat" version="23.1.1.0" targetFramework="MonoAndroid60" />
|
||||
</packages>
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Xamarin.Android.UIPRovider", "Xamarin.Android.UIPRovider\Xamarin.Android.UIPRovider.fsproj", "{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}"
|
||||
EndProject
|
||||
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Xamarin.Android.UIProvider.Runtime", "Xamarin.Android.UIProvider.Runtime\Xamarin.Android.UIProvider.Runtime.fsproj", "{3AAE14BD-F10D-44C0-A09C-685C95B52646}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3AAE14BD-F10D-44C0-A09C-685C95B52646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3AAE14BD-F10D-44C0-A09C-685C95B52646}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3AAE14BD-F10D-44C0-A09C-685C95B52646}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3AAE14BD-F10D-44C0-A09C-685C95B52646}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,524 @@
|
|||
// --------------------------------------------------------------------------------------
|
||||
// Helpers for writing type providers
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
|
||||
namespace ProviderImplementation
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open System.Reflection
|
||||
open System.Text
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
open Microsoft.FSharp.Core.Printf
|
||||
open Microsoft.FSharp.Quotations
|
||||
open Microsoft.FSharp.Quotations.Patterns
|
||||
open Microsoft.FSharp.Reflection
|
||||
open ProviderImplementation.ProvidedTypes
|
||||
|
||||
module internal Debug =
|
||||
|
||||
/// Simulates a real instance of TypeProviderConfig and then creates an instance of the last
|
||||
/// type provider added to a namespace by the type provider constructor
|
||||
let generate (resolutionFolder: string) (runtimeAssembly: string) typeProviderForNamespacesConstructor args =
|
||||
|
||||
let cfg = new TypeProviderConfig(fun _ -> false)
|
||||
let (?<-) cfg prop value =
|
||||
cfg.GetType().GetProperty(prop).GetSetMethod(nonPublic = true).Invoke(cfg, [| box value |]) |> ignore
|
||||
cfg?ResolutionFolder <- resolutionFolder
|
||||
cfg?RuntimeAssembly <- runtimeAssembly
|
||||
cfg?ReferencedAssemblies <- Array.zeroCreate<string> 0
|
||||
|
||||
let typeProviderForNamespaces = typeProviderForNamespacesConstructor cfg :> TypeProviderForNamespaces
|
||||
|
||||
let providedTypeDefinition = typeProviderForNamespaces.Namespaces |> Seq.last |> snd |> Seq.last
|
||||
|
||||
match args with
|
||||
| [||] -> providedTypeDefinition
|
||||
| args ->
|
||||
let typeName =
|
||||
if providedTypeDefinition.IsErased then
|
||||
providedTypeDefinition.Name + (args |> Seq.map (fun s -> ",\"" + (if s = null then "" else s.ToString()) + "\"") |> Seq.reduce (+))
|
||||
else
|
||||
// The type name ends up quite mangled in the dll output if we combine the name using static parameters, so for generated types we don't do that
|
||||
providedTypeDefinition.Name
|
||||
providedTypeDefinition.MakeParametricType(typeName, args)
|
||||
|
||||
/// Returns a string representation of the signature (and optionally also the body) of all the
|
||||
/// types generated by the type provider up to a certain depth and width
|
||||
/// If ignoreOutput is true, this will still visit the full graph, but it will output an empty string to be faster
|
||||
let prettyPrint signatureOnly ignoreOutput maxDepth maxWidth (t: ProvidedTypeDefinition) =
|
||||
|
||||
let ns =
|
||||
[ t.Namespace
|
||||
"Microsoft.FSharp.Core"
|
||||
"Microsoft.FSharp.Core.Operators"
|
||||
"Microsoft.FSharp.Collections"
|
||||
"Microsoft.FSharp.Control"
|
||||
"Microsoft.FSharp.Text" ]
|
||||
|> Set.ofSeq
|
||||
|
||||
let pending = new Queue<_>()
|
||||
let visited = new HashSet<_>()
|
||||
|
||||
let add t =
|
||||
if visited.Add t then
|
||||
pending.Enqueue t
|
||||
|
||||
let fullName (t: Type) =
|
||||
let fullName = t.Namespace + "." + t.Name
|
||||
if fullName.StartsWith "FSI_" then
|
||||
fullName.Substring(fullName.IndexOf('.') + 1)
|
||||
else
|
||||
fullName
|
||||
|
||||
let rec toString useFullName (t: Type) =
|
||||
|
||||
let hasUnitOfMeasure = t.Name.Contains("[")
|
||||
|
||||
let innerToString (t: Type) =
|
||||
match t with
|
||||
| t when t = typeof<bool> -> "bool"
|
||||
| t when t = typeof<obj> -> "obj"
|
||||
| t when t = typeof<int> -> "int"
|
||||
| t when t = typeof<int64> -> "int64"
|
||||
| t when t = typeof<float> -> "float"
|
||||
| t when t = typeof<float32> -> "float32"
|
||||
| t when t = typeof<decimal> -> "decimal"
|
||||
| t when t = typeof<string> -> "string"
|
||||
| t when t = typeof<Void> -> "()"
|
||||
| t when t = typeof<unit> -> "()"
|
||||
| t when t.IsArray -> (t.GetElementType() |> toString useFullName) + "[]"
|
||||
| :? ProvidedTypeDefinition as t ->
|
||||
add t
|
||||
t.Name.Split(',').[0]
|
||||
| t when t.IsGenericType ->
|
||||
let args =
|
||||
if useFullName then
|
||||
t.GetGenericArguments()
|
||||
|> Seq.map (if hasUnitOfMeasure then (fun t -> t.Name) else toString useFullName)
|
||||
else
|
||||
t.GetGenericArguments()
|
||||
|> Seq.map (fun _ -> "_")
|
||||
if FSharpType.IsTuple t then
|
||||
String.concat " * " args
|
||||
elif t.Name.StartsWith "FSharpFunc`" then
|
||||
"(" + (String.concat " -> " args) + ")"
|
||||
else
|
||||
let args = String.concat "," args
|
||||
let name, reverse =
|
||||
match t with
|
||||
| t when hasUnitOfMeasure -> toString useFullName t.UnderlyingSystemType, false
|
||||
| t when t.GetGenericTypeDefinition().Name = typeof<int seq>.GetGenericTypeDefinition().Name -> "seq", true
|
||||
| t when t.GetGenericTypeDefinition().Name = typeof<int list>.GetGenericTypeDefinition().Name -> "list", true
|
||||
| t when t.GetGenericTypeDefinition().Name = typeof<int option>.GetGenericTypeDefinition().Name -> "option", true
|
||||
| t when t.GetGenericTypeDefinition().Name = typeof<int ref>.GetGenericTypeDefinition().Name -> "ref", true
|
||||
| t when t.Name = "FSharpAsync`1" -> "async", true
|
||||
| t when ns.Contains t.Namespace -> t.Name, false
|
||||
| t -> (if useFullName then fullName t else t.Name), false
|
||||
let name = name.Split('`').[0]
|
||||
if reverse then
|
||||
args + " " + name
|
||||
else
|
||||
name + "<" + args + ">"
|
||||
| t when ns.Contains t.Namespace -> t.Name
|
||||
| t when t.IsGenericParameter -> t.Name
|
||||
| t -> if useFullName then fullName t else t.Name
|
||||
|
||||
let rec warnIfWrongAssembly (t:Type) =
|
||||
match t with
|
||||
| :? ProvidedTypeDefinition -> ""
|
||||
| t when t.IsGenericType -> defaultArg (t.GetGenericArguments() |> Seq.map warnIfWrongAssembly |> Seq.tryFind (fun s -> s <> "")) ""
|
||||
| t when t.IsArray -> warnIfWrongAssembly <| t.GetElementType()
|
||||
| t -> if not t.IsGenericParameter && t.Assembly = Assembly.GetExecutingAssembly() then " [DESIGNTIME]" else ""
|
||||
|
||||
if ignoreOutput then
|
||||
""
|
||||
elif hasUnitOfMeasure || t.IsGenericParameter || t.DeclaringType = null then
|
||||
innerToString t + (warnIfWrongAssembly t)
|
||||
else
|
||||
(toString useFullName t.DeclaringType) + "+" + (innerToString t) + (warnIfWrongAssembly t)
|
||||
|
||||
let toSignature (parameters: ParameterInfo[]) =
|
||||
if parameters.Length = 0 then
|
||||
"()"
|
||||
else
|
||||
parameters
|
||||
|> Seq.map (fun p -> p.Name + ":" + (toString true p.ParameterType))
|
||||
|> String.concat " -> "
|
||||
|
||||
let printExpr expr =
|
||||
|
||||
let sb = StringBuilder ()
|
||||
let print (str:string) = sb.Append(str) |> ignore
|
||||
|
||||
let getCurrentIndent() =
|
||||
let lastEnterPos = sb.ToString().LastIndexOf('\n')
|
||||
if lastEnterPos = -1 then sb.Length + 4 else sb.Length - lastEnterPos - 1
|
||||
|
||||
let breakLine indent =
|
||||
print "\n"
|
||||
print (new String(' ', indent))
|
||||
|
||||
let isBigExpression = function
|
||||
| Let _ | NewArray _ | NewTuple _ -> true
|
||||
| _ -> false
|
||||
|
||||
let inline getAttrs attrName m =
|
||||
( ^a : (member GetCustomAttributesData : unit -> IList<CustomAttributeData>) m)
|
||||
|> Seq.filter (fun attr -> attr.Constructor.DeclaringType.Name = attrName)
|
||||
|
||||
let inline hasAttr attrName m =
|
||||
not (Seq.isEmpty (getAttrs attrName m))
|
||||
|
||||
let rec printSeparatedByCommas exprs =
|
||||
match exprs with
|
||||
| [] -> ()
|
||||
| e::es ->
|
||||
printExpr false true e
|
||||
for e in es do
|
||||
print ", "
|
||||
printExpr false true e
|
||||
|
||||
and printCall fromPipe printName (mi:MethodInfo) args =
|
||||
if fromPipe && List.length args = 1 then
|
||||
printName()
|
||||
elif not (hasAttr "CompilationArgumentCountsAttribute" mi) then
|
||||
printName()
|
||||
match args with
|
||||
| [] -> print "()"
|
||||
| arg::args ->
|
||||
print "("
|
||||
let indent = getCurrentIndent()
|
||||
printExpr false true arg
|
||||
for arg in args do
|
||||
print ", "
|
||||
if isBigExpression arg then
|
||||
breakLine indent
|
||||
printExpr false true arg
|
||||
print ")"
|
||||
else
|
||||
print "("
|
||||
printName()
|
||||
for arg in args do
|
||||
print " "
|
||||
printExpr false true arg
|
||||
print ")"
|
||||
|
||||
and printExpr fromPipe needsParens = function
|
||||
| Call (instance, mi, args) ->
|
||||
if mi.Name = "GetArray" && mi.DeclaringType.FullName = "Microsoft.FSharp.Core.LanguagePrimitives+IntrinsicFunctions" then
|
||||
printExpr false true args.Head
|
||||
print ".["
|
||||
printExpr false true args.Tail.Head
|
||||
print "]"
|
||||
elif mi.DeclaringType.IsGenericType && mi.DeclaringType.GetGenericTypeDefinition().Name = typeof<int option>.GetGenericTypeDefinition().Name then
|
||||
if args.IsEmpty then
|
||||
match instance with
|
||||
| None -> print "None"
|
||||
| Some instance ->
|
||||
printExpr false true instance
|
||||
print "."
|
||||
print <| mi.Name.Substring("get_".Length)
|
||||
else
|
||||
print "Some "
|
||||
printExpr false true args.Head
|
||||
elif mi.Name.Contains "." && not args.IsEmpty then
|
||||
// instance method in type extension
|
||||
let printName() =
|
||||
printExpr false true args.Head
|
||||
print "."
|
||||
print (mi.Name.Substring(mi.Name.IndexOf '.' + 1))
|
||||
printCall fromPipe printName mi args.Tail
|
||||
elif mi.Attributes &&& MethodAttributes.SpecialName = MethodAttributes.SpecialName && mi.Name.StartsWith "get_" && args.IsEmpty then
|
||||
// property get
|
||||
match instance with
|
||||
| Some expr -> printExpr false true expr
|
||||
| None -> print (toString false mi.DeclaringType)
|
||||
print "."
|
||||
print <| mi.Name.Substring("get_".Length)
|
||||
elif mi.Name = "op_PipeRight" && args.Length = 2 then
|
||||
printExpr false false args.Head
|
||||
print " |> "
|
||||
match args.Tail.Head with
|
||||
| Lambda (_, (Call(_,_,_) as call)) -> printExpr true false call
|
||||
| _ as expr -> printExpr false false expr
|
||||
else
|
||||
let printName() =
|
||||
match instance with
|
||||
| Some expr -> printExpr false true expr
|
||||
| None -> print (toString false mi.DeclaringType)
|
||||
print "."
|
||||
print mi.Name
|
||||
let isOptional (arg:Expr, param:ParameterInfo) =
|
||||
hasAttr "OptionalArgumentAttribute" param
|
||||
&& arg.ToString() = "Call (None, get_None, [])"
|
||||
let args =
|
||||
mi.GetParameters()
|
||||
|> List.ofArray
|
||||
|> List.zip args
|
||||
|> List.filter (not << isOptional)
|
||||
|> List.map fst
|
||||
printCall fromPipe printName mi args
|
||||
| Let (var1, TupleGet (Var x, 1), Let (var2, TupleGet (Var y, 0), body)) when x = y ->
|
||||
let indent = getCurrentIndent()
|
||||
bprintf sb "let %s, %s = %s" var2.Name var1.Name x.Name
|
||||
breakLine indent
|
||||
printExpr false false body
|
||||
| Let (var, value, body) ->
|
||||
let indent = getCurrentIndent()
|
||||
let usePattern = sprintf "IfThenElse(TypeTest(IDisposable,Coerce(%s,Object)),Call(Some(Call(None,UnboxGeneric,[Coerce(%s,Object)])),Dispose,[]),Value(<null>))" var.Name var.Name
|
||||
let body =
|
||||
match body with
|
||||
| TryFinally (tryExpr, finallyExpr) when finallyExpr.ToString().Replace("\n", null).Replace(" ", null) = usePattern ->
|
||||
bprintf sb "use %s = " var.Name
|
||||
tryExpr
|
||||
| _ ->
|
||||
if var.IsMutable then
|
||||
bprintf sb "let mutable %s = " var.Name
|
||||
else
|
||||
bprintf sb "let %s = " var.Name
|
||||
body
|
||||
match value with
|
||||
| Let _ ->
|
||||
breakLine (indent + 4)
|
||||
printExpr false false value
|
||||
| _ -> printExpr false false value
|
||||
breakLine indent
|
||||
printExpr false false body
|
||||
| Value (null, _) ->
|
||||
print "null"
|
||||
| Value (value, typ) when typ = typeof<string> && (value :?> string).Contains("\\") ->
|
||||
bprintf sb "@%A" value
|
||||
| Value (value, _) ->
|
||||
bprintf sb "%A" value
|
||||
| Var (var) ->
|
||||
print var.Name
|
||||
| NewObject (ci, args) ->
|
||||
let getSourceConstructFlags (attr:CustomAttributeData) =
|
||||
let arg = attr.ConstructorArguments
|
||||
|> Seq.filter (fun arg -> arg.ArgumentType.Name = "SourceConstructFlags")
|
||||
|> Seq.head
|
||||
arg.Value :?> int
|
||||
let compilationMappings = getAttrs "CompilationMappingAttribute" ci.DeclaringType
|
||||
if not (Seq.isEmpty compilationMappings) && (getSourceConstructFlags (Seq.head compilationMappings)) = int SourceConstructFlags.RecordType then
|
||||
print "{ "
|
||||
let indent = getCurrentIndent()
|
||||
let recordFields = FSharpType.GetRecordFields(ci.DeclaringType)
|
||||
args |> List.iteri (fun i arg ->
|
||||
if i > 0 then
|
||||
breakLine indent
|
||||
print recordFields.[i].Name
|
||||
print " = "
|
||||
printExpr false false arg)
|
||||
print " }"
|
||||
else
|
||||
print "(new "
|
||||
print (toString false ci.DeclaringType)
|
||||
print "("
|
||||
printSeparatedByCommas args
|
||||
print "))"
|
||||
| NewDelegate (typ, vars, expr) ->
|
||||
print "new "
|
||||
print (toString false typ)
|
||||
match expr with
|
||||
| Var v when not vars.IsEmpty && vars.Tail.IsEmpty && vars.Head = v -> print "(id)"
|
||||
| _ ->
|
||||
let indent = getCurrentIndent()
|
||||
if vars.IsEmpty then
|
||||
print "(fun () -> "
|
||||
else
|
||||
print "(fun"
|
||||
for var in vars do
|
||||
bprintf sb " (%s:%s)" var.Name (toString false var.Type)
|
||||
print " -> "
|
||||
if isBigExpression expr then
|
||||
breakLine (indent + 4)
|
||||
printExpr false false expr
|
||||
else
|
||||
printExpr false false expr
|
||||
print ")"
|
||||
| NewTuple (exprs) ->
|
||||
if needsParens then print "("
|
||||
let indent = getCurrentIndent()
|
||||
printExpr false true exprs.Head
|
||||
for e in exprs.Tail do
|
||||
print ","
|
||||
breakLine indent
|
||||
printExpr false true e
|
||||
if needsParens then print ")"
|
||||
| NewArray (_, exprs) ->
|
||||
if exprs.Length = 0 then print "[| |]"
|
||||
else
|
||||
print "[| "
|
||||
let indent = getCurrentIndent()
|
||||
printExpr false true exprs.Head
|
||||
for e in exprs.Tail do
|
||||
breakLine indent
|
||||
printExpr false true e
|
||||
print " |]"
|
||||
| Coerce (expr, typ) ->
|
||||
print "("
|
||||
printExpr false false expr
|
||||
print " :> "
|
||||
print (toString false typ)
|
||||
print ")"
|
||||
| TupleGet (expr, index) ->
|
||||
print "(let "
|
||||
let rec getTupleLength (typ:Type) =
|
||||
let length = typ.GetGenericArguments().Length
|
||||
if length = 0 then // happens in the Apiary provider
|
||||
let typeNameSuffix = typ.Name.Substring(typ.Name.IndexOf('`') + 1)
|
||||
typeNameSuffix.Substring(0, typeNameSuffix.IndexOf('[')) |> Int32.Parse
|
||||
else
|
||||
let lastItem = typ.GetGenericArguments() |> Seq.last
|
||||
if lastItem.Name.StartsWith "Tuple`"
|
||||
then length + getTupleLength lastItem - 1
|
||||
else length
|
||||
let tupleLength = getTupleLength expr.Type
|
||||
let varName = "t" + (string (index + 1))
|
||||
for i in 0..tupleLength-1 do
|
||||
if i = index then
|
||||
print varName
|
||||
else
|
||||
print "_"
|
||||
if i <> tupleLength-1 then
|
||||
print ","
|
||||
print " = "
|
||||
printExpr false false expr
|
||||
print (" in " + varName + ")")
|
||||
| expr -> print (expr.ToString())
|
||||
|
||||
printExpr false false expr
|
||||
sb.ToString()
|
||||
|
||||
let sb = StringBuilder ()
|
||||
|
||||
let print (str: string) =
|
||||
if not ignoreOutput then
|
||||
sb.Append(str) |> ignore
|
||||
|
||||
let println() =
|
||||
if not ignoreOutput then
|
||||
sb.AppendLine() |> ignore
|
||||
|
||||
let printMember (memberInfo: MemberInfo) =
|
||||
|
||||
let print str =
|
||||
print " "
|
||||
print str
|
||||
println()
|
||||
|
||||
let getMethodBody (m: ProvidedMethod) =
|
||||
seq { if not m.IsStatic then yield (ProvidedTypeDefinition.EraseType m.DeclaringType)
|
||||
for param in m.GetParameters() do yield (ProvidedTypeDefinition.EraseType param.ParameterType) }
|
||||
|> Seq.map (fun typ -> Expr.Value(null, typ))
|
||||
|> Array.ofSeq
|
||||
|> m.GetInvokeCodeInternal false
|
||||
|
||||
let getConstructorBody (c: ProvidedConstructor) =
|
||||
if c.IsImplicitCtor then Expr.Value(()) else
|
||||
seq { for param in c.GetParameters() do yield (ProvidedTypeDefinition.EraseType param.ParameterType) }
|
||||
|> Seq.map (fun typ -> Expr.Value(null, typ))
|
||||
|> Array.ofSeq
|
||||
|> c.GetInvokeCodeInternal false
|
||||
|
||||
let printExpr x =
|
||||
if not ignoreOutput then
|
||||
let rec removeParams x =
|
||||
match x with
|
||||
| Let (_, Value(null, _), body) -> removeParams body
|
||||
| _ -> x
|
||||
let formattedExpr = printExpr (removeParams x)
|
||||
print formattedExpr
|
||||
println()
|
||||
|
||||
let printObj x =
|
||||
if ignoreOutput then
|
||||
""
|
||||
else
|
||||
sprintf "\n%O\n" x
|
||||
|
||||
let getName (m:MemberInfo) =
|
||||
if memberInfo.Name.Contains(" ") then
|
||||
"``" + m.Name + "``"
|
||||
else
|
||||
m.Name
|
||||
|
||||
match memberInfo with
|
||||
|
||||
| :? ProvidedConstructor as cons ->
|
||||
if not ignoreOutput then
|
||||
print <| "new : " +
|
||||
(toSignature <| cons.GetParameters()) + " -> " +
|
||||
(toString true memberInfo.DeclaringType)
|
||||
if not signatureOnly then
|
||||
cons |> getConstructorBody |> printExpr
|
||||
|
||||
| :? ProvidedLiteralField as field ->
|
||||
let value =
|
||||
if signatureOnly then ""
|
||||
else field.GetRawConstantValue() |> printObj
|
||||
if not ignoreOutput then
|
||||
print <| "val " + (getName field) + ": " +
|
||||
(toString true field.FieldType) +
|
||||
value
|
||||
|
||||
| :? ProvidedProperty as prop ->
|
||||
if not ignoreOutput then
|
||||
print <| (if prop.IsStatic then "static " else "") + "member " +
|
||||
(getName prop) + ": " + (toString true prop.PropertyType) +
|
||||
" with " + (if prop.CanRead && prop.CanWrite then "get, set" else if prop.CanRead then "get" else "set")
|
||||
if not signatureOnly then
|
||||
if prop.CanRead then
|
||||
getMethodBody (prop.GetGetMethod() :?> ProvidedMethod) |> printExpr
|
||||
if prop.CanWrite then
|
||||
getMethodBody (prop.GetSetMethod() :?> ProvidedMethod) |> printExpr
|
||||
|
||||
| :? ProvidedMethod as m ->
|
||||
if m.Attributes &&& MethodAttributes.SpecialName <> MethodAttributes.SpecialName then
|
||||
if not ignoreOutput then
|
||||
print <| (if m.IsStatic then "static " else "") + "member " +
|
||||
(getName m) + ": " + (toSignature <| m.GetParameters()) +
|
||||
" -> " + (toString true m.ReturnType)
|
||||
if not signatureOnly then
|
||||
m |> getMethodBody |> printExpr
|
||||
|
||||
| _ -> ()
|
||||
|
||||
add t
|
||||
|
||||
let currentDepth = ref 0
|
||||
|
||||
while pending.Count <> 0 && !currentDepth <= maxDepth do
|
||||
let pendingForThisDepth = new List<_>(pending)
|
||||
pending.Clear()
|
||||
let pendingForThisDepth =
|
||||
pendingForThisDepth
|
||||
|> Seq.sortBy (fun m -> m.Name)
|
||||
|> Seq.truncate maxWidth
|
||||
for t in pendingForThisDepth do
|
||||
//Disabled because not working on Mono
|
||||
//for attr in t.GetCustomAttributesData() do
|
||||
// print <| (sprintf "[<%A>]" attr).Replace("Microsoft.FSharp.Core.", null).Replace("CompilerServices.", null).Replace("Attribute(", "(")
|
||||
// println()
|
||||
match t with
|
||||
| t when FSharpType.IsRecord t-> "record "
|
||||
| t when FSharpType.IsModule t -> "module "
|
||||
| t when t.IsValueType -> "struct "
|
||||
| t when t.IsClass && t.IsSealed && t.IsAbstract -> "static class "
|
||||
| t when t.IsClass && t.IsAbstract -> "abstract class "
|
||||
| t when t.IsClass -> "class "
|
||||
| _ -> ""
|
||||
|> print
|
||||
print (toString true t)
|
||||
if t.BaseType <> typeof<obj> then
|
||||
print " : "
|
||||
print (toString true t.BaseType)
|
||||
println()
|
||||
t.GetMembers()
|
||||
|> Seq.sortBy (fun m -> m.Name)
|
||||
|> Seq.iter printMember
|
||||
println()
|
||||
currentDepth := !currentDepth + 1
|
||||
|
||||
sb.ToString()
|
|
@ -0,0 +1,470 @@
|
|||
// Copyright (c) Microsoft Corporation 2005-2014 and other contributors.
|
||||
// This sample code is provided "as is" without warranty of any kind.
|
||||
// We disclaim all warranties, either express or implied, including the
|
||||
// warranties of merchantability and fitness for a particular purpose.
|
||||
//
|
||||
// This file contains a set of helper types and methods for providing types in an implementation
|
||||
// of ITypeProvider.
|
||||
//
|
||||
// This code has been modified and is appropriate for use in conjunction with the F# 3.0-4.0 releases
|
||||
|
||||
|
||||
namespace ProviderImplementation.ProvidedTypes
|
||||
|
||||
open System
|
||||
open System.Reflection
|
||||
open System.Linq.Expressions
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
|
||||
/// Represents an erased provided parameter
|
||||
type ProvidedParameter =
|
||||
inherit ParameterInfo
|
||||
new : parameterName: string * parameterType: Type * ?isOut:bool * ?optionalValue:obj -> ProvidedParameter
|
||||
member IsParamArray : bool with get,set
|
||||
|
||||
/// Represents a provided static parameter.
|
||||
type ProvidedStaticParameter =
|
||||
inherit ParameterInfo
|
||||
new : parameterName: string * parameterType:Type * ?parameterDefaultValue:obj -> ProvidedStaticParameter
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Represents an erased provided constructor.
|
||||
type ProvidedConstructor =
|
||||
inherit ConstructorInfo
|
||||
|
||||
/// Create a new provided constructor. It is not initially associated with any specific provided type definition.
|
||||
new : parameters: ProvidedParameter list -> ProvidedConstructor
|
||||
|
||||
/// Add a 'System.Obsolete' attribute to this provided constructor
|
||||
member AddObsoleteAttribute : message: string * ?isError: bool -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Set the quotation used to compute the implementation of invocations of this constructor.
|
||||
member InvokeCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// FSharp.Data addition: this method is used by Debug.fs
|
||||
member internal GetInvokeCodeInternal : bool -> (Quotations.Expr [] -> Quotations.Expr)
|
||||
|
||||
/// Set the target and arguments of the base constructor call. Only used for generated types.
|
||||
member BaseConstructorCall : (Quotations.Expr list -> ConstructorInfo * Quotations.Expr list) with set
|
||||
|
||||
/// Set a flag indicating that the constructor acts like an F# implicit constructor, so the
|
||||
/// parameters of the constructor become fields and can be accessed using Expr.GlobalVar with the
|
||||
/// same name.
|
||||
member IsImplicitCtor : bool with get,set
|
||||
|
||||
/// Add definition location information to the provided constructor.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
member IsTypeInitializer : bool with get,set
|
||||
|
||||
type ProvidedMethod =
|
||||
inherit MethodInfo
|
||||
|
||||
/// Create a new provided method. It is not initially associated with any specific provided type definition.
|
||||
new : methodName:string * parameters: ProvidedParameter list * returnType: Type -> ProvidedMethod
|
||||
|
||||
/// Add XML documentation information to this provided method
|
||||
member AddObsoleteAttribute : message: string * ?isError: bool -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
member AddMethodAttrs : attributes:MethodAttributes -> unit
|
||||
|
||||
/// Set the method attributes of the method. By default these are simple 'MethodAttributes.Public'
|
||||
member SetMethodAttrs : attributes:MethodAttributes -> unit
|
||||
|
||||
/// Get or set a flag indicating if the property is static.
|
||||
member IsStaticMethod : bool with get, set
|
||||
|
||||
/// Set the quotation used to compute the implementation of invocations of this method.
|
||||
member InvokeCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// FSharp.Data addition: this method is used by Debug.fs
|
||||
member internal GetInvokeCodeInternal : bool -> (Quotations.Expr [] -> Quotations.Expr)
|
||||
|
||||
/// Add definition location information to the provided type definition.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
/// Add a custom attribute to the provided method definition.
|
||||
member AddCustomAttribute : CustomAttributeData -> unit
|
||||
|
||||
/// Define the static parameters available on a statically parameterized method
|
||||
member DefineStaticParameters : parameters: ProvidedStaticParameter list * instantiationFunction: (string -> obj[] -> ProvidedMethod) -> unit
|
||||
|
||||
/// Represents an erased provided property.
|
||||
type ProvidedProperty =
|
||||
inherit PropertyInfo
|
||||
|
||||
/// Create a new provided type. It is not initially associated with any specific provided type definition.
|
||||
new : propertyName: string * propertyType: Type * ?parameters:ProvidedParameter list -> ProvidedProperty
|
||||
|
||||
/// Add a 'System.Obsolete' attribute to this provided property
|
||||
member AddObsoleteAttribute : message: string * ?isError: bool -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Get or set a flag indicating if the property is static.
|
||||
/// FSharp.Data addition: the getter is used by Debug.fs
|
||||
member IsStatic : bool with get,set
|
||||
|
||||
/// Set the quotation used to compute the implementation of gets of this property.
|
||||
member GetterCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// Set the function used to compute the implementation of sets of this property.
|
||||
member SetterCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// Add definition location information to the provided type definition.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
/// Add a custom attribute to the provided property definition.
|
||||
member AddCustomAttribute : CustomAttributeData -> unit
|
||||
|
||||
/// Represents an erased provided property.
|
||||
type ProvidedEvent =
|
||||
inherit EventInfo
|
||||
|
||||
/// Create a new provided type. It is not initially associated with any specific provided type definition.
|
||||
new : propertyName: string * eventHandlerType: Type -> ProvidedEvent
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Get or set a flag indicating if the property is static.
|
||||
member IsStatic : bool with set
|
||||
|
||||
/// Set the quotation used to compute the implementation of gets of this property.
|
||||
member AdderCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// Set the function used to compute the implementation of sets of this property.
|
||||
member RemoverCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// Add definition location information to the provided type definition.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
/// Represents an erased provided field.
|
||||
type ProvidedLiteralField =
|
||||
inherit FieldInfo
|
||||
|
||||
/// Create a new provided field. It is not initially associated with any specific provided type definition.
|
||||
new : fieldName: string * fieldType: Type * literalValue: obj -> ProvidedLiteralField
|
||||
|
||||
/// Add a 'System.Obsolete' attribute to this provided field
|
||||
member AddObsoleteAttribute : message: string * ?isError: bool -> unit
|
||||
|
||||
/// Add XML documentation information to this provided field
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided field, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided field, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add definition location information to the provided field.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
/// Represents an erased provided field.
|
||||
type ProvidedField =
|
||||
inherit FieldInfo
|
||||
|
||||
/// Create a new provided field. It is not initially associated with any specific provided type definition.
|
||||
new : fieldName: string * fieldType: Type -> ProvidedField
|
||||
|
||||
/// Add a 'System.Obsolete' attribute to this provided field
|
||||
member AddObsoleteAttribute : message: string * ?isError: bool -> unit
|
||||
|
||||
/// Add XML documentation information to this provided field
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided field, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided field, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add definition location information to the provided field definition.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
member SetFieldAttributes : attributes : FieldAttributes -> unit
|
||||
|
||||
/// Add a custom attribute to the provided property definition.
|
||||
member AddCustomAttribute : CustomAttributeData -> unit
|
||||
|
||||
/// Represents the type constructor in a provided symbol type.
|
||||
[<NoComparison>]
|
||||
type SymbolKind =
|
||||
/// Indicates that the type constructor is for a single-dimensional array
|
||||
| SDArray
|
||||
/// Indicates that the type constructor is for a multi-dimensional array
|
||||
| Array of int
|
||||
/// Indicates that the type constructor is for pointer types
|
||||
| Pointer
|
||||
/// Indicates that the type constructor is for byref types
|
||||
| ByRef
|
||||
/// Indicates that the type constructor is for named generic types
|
||||
| Generic of Type
|
||||
/// Indicates that the type constructor is for abbreviated types
|
||||
| FSharpTypeAbbreviation of (Assembly * string * string[])
|
||||
|
||||
/// Represents an array or other symbolic type involving a provided type as the argument.
|
||||
/// See the type provider spec for the methods that must be implemented.
|
||||
/// Note that the type provider specification does not require us to implement pointer-equality for provided types.
|
||||
[<Class>]
|
||||
type ProvidedSymbolType =
|
||||
inherit Type
|
||||
|
||||
/// Returns the kind of this symbolic type
|
||||
member Kind : SymbolKind
|
||||
|
||||
/// Return the provided types used as arguments of this symbolic type
|
||||
member Args : list<Type>
|
||||
|
||||
|
||||
/// Helpers to build symbolic provided types
|
||||
[<Class>]
|
||||
type ProvidedTypeBuilder =
|
||||
|
||||
/// Like typ.MakeGenericType, but will also work with unit-annotated types
|
||||
static member MakeGenericType: genericTypeDefinition: Type * genericArguments: Type list -> Type
|
||||
|
||||
/// Like methodInfo.MakeGenericMethod, but will also work with unit-annotated types and provided types
|
||||
static member MakeGenericMethod: genericMethodDefinition: MethodInfo * genericArguments: Type list -> MethodInfo
|
||||
|
||||
/// Helps create erased provided unit-of-measure annotations.
|
||||
[<Class>]
|
||||
type ProvidedMeasureBuilder =
|
||||
|
||||
/// The ProvidedMeasureBuilder for building measures.
|
||||
static member Default : ProvidedMeasureBuilder
|
||||
|
||||
/// Gets the measure indicating the "1" unit of measure, that is the unitless measure.
|
||||
member One : Type
|
||||
|
||||
/// Returns the measure indicating the product of two units of measure, e.g. kg * m
|
||||
member Product : measure1: Type * measure1: Type -> Type
|
||||
|
||||
/// Returns the measure indicating the inverse of two units of measure, e.g. 1 / s
|
||||
member Inverse : denominator: Type -> Type
|
||||
|
||||
/// Returns the measure indicating the ratio of two units of measure, e.g. kg / m
|
||||
member Ratio : numerator: Type * denominator: Type -> Type
|
||||
|
||||
/// Returns the measure indicating the square of a unit of measure, e.g. m * m
|
||||
member Square : ``measure``: Type -> Type
|
||||
|
||||
/// Returns the measure for an SI unit from the F# core library, where the string is in capitals and US spelling, e.g. Meter
|
||||
member SI : unitName:string -> Type
|
||||
|
||||
/// Returns a type where the type has been annotated with the given types and/or units-of-measure.
|
||||
/// e.g. float<kg>, Vector<int, kg>
|
||||
member AnnotateType : basic: Type * argument: Type list -> Type
|
||||
|
||||
|
||||
/// Represents a provided type definition.
|
||||
type ProvidedTypeDefinition =
|
||||
inherit Type
|
||||
|
||||
/// Create a new provided type definition in a namespace.
|
||||
new : assembly: Assembly * namespaceName: string * className: string * baseType: Type option -> ProvidedTypeDefinition
|
||||
|
||||
/// Create a new provided type definition, to be located as a nested type in some type definition.
|
||||
new : className : string * baseType: Type option -> ProvidedTypeDefinition
|
||||
|
||||
/// Add the given type as an implemented interface.
|
||||
member AddInterfaceImplementation : interfaceType: Type -> unit
|
||||
|
||||
/// Add the given function as a set of on-demand computed interfaces.
|
||||
member AddInterfaceImplementationsDelayed : interfacesFunction:(unit -> Type list)-> unit
|
||||
|
||||
/// Specifies that the given method body implements the given method declaration.
|
||||
member DefineMethodOverride : methodInfoBody: ProvidedMethod * methodInfoDeclaration: MethodInfo -> unit
|
||||
|
||||
/// Add a 'System.Obsolete' attribute to this provided type definition
|
||||
member AddObsoleteAttribute : message: string * ?isError: bool -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Set the base type
|
||||
member SetBaseType : Type -> unit
|
||||
|
||||
/// Set the base type to a lazily evaluated value. Use this to delay realization of the base type as late as possible.
|
||||
member SetBaseTypeDelayed : baseTypeFunction:(unit -> Type) -> unit
|
||||
|
||||
/// Set underlying type for generated enums
|
||||
member SetEnumUnderlyingType : Type -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary.
|
||||
/// The documentation is only computed once.
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Set the attributes on the provided type. This fully replaces the default TypeAttributes.
|
||||
member SetAttributes : TypeAttributes -> unit
|
||||
|
||||
/// Reset the enclosing type (for generated nested types)
|
||||
member ResetEnclosingType: enclosingType:Type -> unit
|
||||
|
||||
/// Add a method, property, nested type or other member to a ProvidedTypeDefinition
|
||||
member AddMember : memberInfo:MemberInfo -> unit
|
||||
|
||||
/// Add a set of members to a ProvidedTypeDefinition
|
||||
member AddMembers : memberInfos:list<#MemberInfo> -> unit
|
||||
|
||||
/// Add a member to a ProvidedTypeDefinition, delaying computation of the members until required by the compilation context.
|
||||
member AddMemberDelayed : memberFunction:(unit -> #MemberInfo) -> unit
|
||||
|
||||
/// Add a set of members to a ProvidedTypeDefinition, delaying computation of the members until required by the compilation context.
|
||||
member AddMembersDelayed : membersFunction:(unit -> list<#MemberInfo>) -> unit
|
||||
|
||||
/// Add the types of the generated assembly as generative types, where types in namespaces get hierarchically positioned as nested types.
|
||||
member AddAssemblyTypesAsNestedTypesDelayed : assemblyFunction:(unit -> Assembly) -> unit
|
||||
|
||||
/// Define the static parameters available on a statically parameterized type
|
||||
member DefineStaticParameters : parameters: ProvidedStaticParameter list * instantiationFunction: (string -> obj[] -> ProvidedTypeDefinition) -> unit
|
||||
|
||||
/// Add definition location information to the provided type definition.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
/// Suppress System.Object entries in intellisense menus in instances of this provided type
|
||||
member HideObjectMethods : bool with set
|
||||
|
||||
/// Disallows the use of the null literal.
|
||||
member NonNullable : bool with set
|
||||
|
||||
/// Get or set a flag indicating if the ProvidedTypeDefinition is erased
|
||||
member IsErased : bool with get,set
|
||||
|
||||
/// Get or set a flag indicating if the ProvidedTypeDefinition has type-relocation suppressed
|
||||
[<Experimental("SuppressRelocation is a workaround and likely to be removed")>]
|
||||
member SuppressRelocation : bool with get,set
|
||||
|
||||
/// FSharp.Data addition: this method is used by Debug.fs
|
||||
member MakeParametricType : name:string * args:obj[] -> ProvidedTypeDefinition
|
||||
|
||||
/// Add a custom attribute to the provided type definition.
|
||||
member AddCustomAttribute : CustomAttributeData -> unit
|
||||
|
||||
/// Emulate the F# type provider type erasure mechanism to get the
|
||||
/// actual (erased) type. We erase ProvidedTypes to their base type
|
||||
/// and we erase array of provided type to array of base type. In the
|
||||
/// case of generics all the generic type arguments are also recursively
|
||||
/// replaced with the erased-to types
|
||||
static member EraseType : typ:Type -> Type
|
||||
|
||||
/// Get or set a utility function to log the creation of root Provided Type. Used to debug caching/invalidation.
|
||||
static member Logger : (string -> unit) option ref
|
||||
|
||||
/// A provided generated assembly
|
||||
type ProvidedAssembly =
|
||||
/// Create a provided generated assembly
|
||||
new : assemblyFileName:string -> ProvidedAssembly
|
||||
|
||||
/// Emit the given provided type definitions as part of the assembly
|
||||
/// and adjust the 'Assembly' property of all provided type definitions to return that
|
||||
/// assembly.
|
||||
///
|
||||
/// The assembly is only emitted when the Assembly property on the root type is accessed for the first time.
|
||||
/// The host F# compiler does this when processing a generative type declaration for the type.
|
||||
member AddTypes : types : ProvidedTypeDefinition list -> unit
|
||||
|
||||
/// <summary>
|
||||
/// Emit the given nested provided type definitions as part of the assembly.
|
||||
/// and adjust the 'Assembly' property of all provided type definitions to return that
|
||||
/// assembly.
|
||||
/// </summary>
|
||||
/// <param name="enclosingTypeNames">A path of type names to wrap the generated types. The generated types are then generated as nested types.</param>
|
||||
member AddNestedTypes : types : ProvidedTypeDefinition list * enclosingGeneratedTypeNames: string list -> unit
|
||||
|
||||
#if FX_NO_LOCAL_FILESYSTEM
|
||||
#else
|
||||
/// Register that a given file is a provided generated assembly
|
||||
static member RegisterGenerated : fileName:string -> Assembly
|
||||
#endif
|
||||
|
||||
|
||||
/// A base type providing default implementations of type provider functionality when all provided
|
||||
/// types are of type ProvidedTypeDefinition.
|
||||
type TypeProviderForNamespaces =
|
||||
|
||||
/// Initializes a type provider to provide the types in the given namespace.
|
||||
new : namespaceName:string * types: ProvidedTypeDefinition list -> TypeProviderForNamespaces
|
||||
|
||||
/// Initializes a type provider
|
||||
new : unit -> TypeProviderForNamespaces
|
||||
|
||||
/// Invoked by the type provider to add a namespace of provided types in the specification of the type provider.
|
||||
member AddNamespace : namespaceName:string * types: ProvidedTypeDefinition list -> unit
|
||||
|
||||
/// Invoked by the type provider to get all provided namespaces with their provided types.
|
||||
member Namespaces : seq<string * ProvidedTypeDefinition list>
|
||||
|
||||
/// Invoked by the type provider to invalidate the information provided by the provider
|
||||
member Invalidate : unit -> unit
|
||||
|
||||
/// Invoked by the host of the type provider to get the static parameters for a method.
|
||||
member GetStaticParametersForMethod : MethodBase -> ParameterInfo[]
|
||||
|
||||
/// Invoked by the host of the type provider to apply the static argumetns for a method.
|
||||
member ApplyStaticArgumentsForMethod : MethodBase * string * obj[] -> MethodBase
|
||||
|
||||
#if FX_NO_LOCAL_FILESYSTEM
|
||||
#else
|
||||
/// AssemblyResolve handler. Default implementation searches <assemblyname>.dll file in registered folders
|
||||
abstract ResolveAssembly : System.ResolveEventArgs -> Assembly
|
||||
default ResolveAssembly : System.ResolveEventArgs -> Assembly
|
||||
|
||||
/// Registers custom probing path that can be used for probing assemblies
|
||||
member RegisterProbingFolder : folder: string -> unit
|
||||
|
||||
/// Registers location of RuntimeAssembly (from TypeProviderConfig) as probing folder
|
||||
member RegisterRuntimeAssemblyLocationAsProbingFolder : config: TypeProviderConfig -> unit
|
||||
|
||||
#endif
|
||||
|
||||
[<CLIEvent>]
|
||||
member Disposing : IEvent<EventHandler,EventArgs>
|
||||
|
||||
interface ITypeProvider
|
|
@ -0,0 +1,317 @@
|
|||
namespace Xamarin.Android.UIProvider
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open System.IO
|
||||
open System.Linq
|
||||
open System.Xml.Linq
|
||||
open System.Reflection
|
||||
open ProviderImplementation.ProvidedTypes
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
open FSharp.Quotations
|
||||
open Android
|
||||
open Android.Views
|
||||
open ExtCore
|
||||
|
||||
module MoreExt =
|
||||
type Text.StringBuilder with
|
||||
member x.Yield (_) = x
|
||||
[<CustomOperation("append")>]
|
||||
member x.append (sb:Text.StringBuilder, str:string) = sb.Append str
|
||||
[<CustomOperation("appendLine")>]
|
||||
member x.appendLine (sb:Text.StringBuilder, str:string) = sb.AppendLine str
|
||||
member x.Run sb = sb.ToString()
|
||||
|
||||
[<AutoOpen>]
|
||||
module Extensions =
|
||||
type BindingFlags with
|
||||
static member PublicStatic = BindingFlags.Public ||| BindingFlags.Static
|
||||
static member All = BindingFlags.Public ||| BindingFlags.Instance ||| BindingFlags.NonPublic
|
||||
|
||||
open Quotations.Patterns
|
||||
let tryGetMi e = Option.map (fun (_,mi,_) -> mi) ((|Call|_|) e)
|
||||
type ProvidedConstructor with
|
||||
|
||||
member x.Yield (_) = x
|
||||
|
||||
[<CustomOperation("invokeCode")>]
|
||||
member x.invokeCode (p:ProvidedConstructor, f) = p.InvokeCode <- f;p
|
||||
|
||||
[<CustomOperation("baseConstructorCall")>]
|
||||
member x.baseConstructorCall (p:ProvidedConstructor, f) = p.BaseConstructorCall <- f;p
|
||||
|
||||
module File =
|
||||
let log str= Console.WriteLine(str:string)
|
||||
|
||||
//TODO switch watcher to a type and implement IDisposable and make Invalidate an observable
|
||||
//This would mean that openWithWatcher would return a watcher that could be used to subscribe to invalidate
|
||||
//changes rather than pass in the TP's Invalidate method in. This is more or less the pattern used by the FileSystemProvider.
|
||||
let watch path invalidator =
|
||||
let getLastWrite() = File.GetLastWriteTime path
|
||||
let lastWrite = ref (getLastWrite())
|
||||
|
||||
let watcher =
|
||||
let path = Path.GetDirectoryName path
|
||||
let name = Path.GetFileName path
|
||||
new FileSystemWatcher(Filter=name, Path=path, EnableRaisingEvents=true)
|
||||
|
||||
let checkForChanges _ =
|
||||
let curr = getLastWrite()
|
||||
if !lastWrite <> curr then
|
||||
log ("Invalidated " + path)
|
||||
lastWrite := curr
|
||||
invalidator()
|
||||
do
|
||||
watcher.Changed.Add checkForChanges
|
||||
watcher.Renamed.Add checkForChanges
|
||||
watcher.Deleted.Add checkForChanges
|
||||
watcher :> IDisposable
|
||||
|
||||
type Model =
|
||||
{ElementName : string; Id : string; Children : Model list }
|
||||
member x.MappingName = "android/widget/" + x.ElementName
|
||||
|
||||
type Scene =
|
||||
{FileName : string; Elements : Model list}
|
||||
|
||||
//type Reflection private () =
|
||||
// static let CallMethodInfo =
|
||||
// let flags = BindingFlags.NonPublic ||| BindingFlags.Static
|
||||
// typeof<Reflection>.GetMethod("DoUnbox", flags).GetGenericMethodDefinition()
|
||||
|
||||
// static member private DoUnbox<'T>(value: obj) =
|
||||
// let value: 'T = unbox value
|
||||
// value
|
||||
|
||||
// static member Unbox(value: obj, typeOfValue: Type) =
|
||||
// CallMethodInfo.MakeGenericMethod(typeOfValue).Invoke(null, [|value|]) :?> _
|
||||
|
||||
type Reflection =
|
||||
static member getSlice<'a when 'a :> View> (instance:Expr) (literalField:FieldInfo)=
|
||||
match <@@ (null : View).FindViewById<'a>(0) @@> with
|
||||
| Patterns.Call(_,mi,_) -> Expr.Call(Expr.Coerce(instance, typeof<View>), mi, [Expr.FieldGet(literalField)])
|
||||
| q -> failwithf "Bad quotation %A" q
|
||||
|
||||
//<@@ (%%coercedInstance : View).FindViewById<'a>(%%getField) @@>
|
||||
//<@@ (%%Expr.Coerce(instance, typeof<View>) : View).FindViewById<'a>(%%Expr.FieldGet(literalField)) @@>
|
||||
|
||||
static member lazyFieldGen<'a when 'a : null and
|
||||
'a : equality and
|
||||
'a :> View> (instance:Expr, controlField:Expr, controlFieldInfo:FieldInfo, literalFieldId:FieldInfo) =
|
||||
let controlField = Expr.Cast<'a>(controlField)
|
||||
let lf = Reflection.getSlice<'a> instance literalFieldId
|
||||
|
||||
<@@ match %controlField with
|
||||
| null ->
|
||||
%%Expr.FieldSet(instance, controlFieldInfo, lf)
|
||||
%controlField
|
||||
| other -> other @@>
|
||||
|
||||
|
||||
[<AbstractClass>]
|
||||
type AndroidDesignerProvider<'T>(config: TypeProviderConfig, ns, name) as this =
|
||||
inherit TypeProviderForNamespaces()
|
||||
let basepath = @"/Library/Frameworks/Xamarin.Android.framework/Versions/6.1.99-76/lib/xbuild-frameworks/MonoAndroid/v6.0/"
|
||||
let runtimePath = @"/Library/Frameworks/Xamarin.Android.framework/Versions/6.1.99-76/lib/mono/2.1/"
|
||||
let assemblyName = "Mono.Android.dll"
|
||||
|
||||
do
|
||||
this.RegisterProbingFolder runtimePath
|
||||
this.RegisterProbingFolder basepath
|
||||
//TODO add folder properly
|
||||
|
||||
let asm = Assembly.GetExecutingAssembly()
|
||||
let rootType = ProvidedTypeDefinition(asm, ns, name, None, HideObjectMethods=true, IsErased=false)
|
||||
let watchedFiles = ResizeArray<IDisposable>()
|
||||
|
||||
let androidTypeMap =
|
||||
let androidAssembly =
|
||||
Assembly.LoadFrom(Path.Combine(basepath, assemblyName))
|
||||
|
||||
androidAssembly.ExportedTypes
|
||||
|> Seq.choose (fun t -> t.GetCustomAttribute<Android.Runtime.RegisterAttribute>()
|
||||
|> Option.ofObj
|
||||
|> Option.map (fun registerAttrib -> registerAttrib.Name, (registerAttrib, t)))
|
||||
|> Map.ofSeq
|
||||
|
||||
let cleanupId (id:string) = id.Replace("@+id/", "")
|
||||
|
||||
//CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android", "1.0")
|
||||
let mkGeneratedCodeAttribute tool version =
|
||||
{ new CustomAttributeData() with
|
||||
member __.Constructor = typeof<CodeDom.Compiler.GeneratedCodeAttribute>.GetConstructors().[0]
|
||||
member __.ConstructorArguments =
|
||||
upcast [| CustomAttributeTypedArgument(typeof<string>, tool); CustomAttributeTypedArgument(typeof<string>, version) |]
|
||||
member __.NamedArguments = upcast [| |] }
|
||||
|
||||
|
||||
let getResourceModel filename =
|
||||
let resourceModel = Resources.getModel filename
|
||||
//build provided model for resource IDS so they can be used in the
|
||||
// provided types to retrieve resource id's properly
|
||||
let generatedResource =
|
||||
match resourceModel.Model with
|
||||
| Some(model) ->
|
||||
let resourceType = ProvidedTypeDefinition("Resource", Some(typeof<obj>), IsErased=false)
|
||||
let idLookup = Dictionary<_,_>()
|
||||
for KeyValue(key,value) in model do
|
||||
let group = ProvidedTypeDefinition(key, Some(typeof<obj>), IsErased=false)
|
||||
for {Name=item; Id= value} in value do
|
||||
let plf = ProvidedLiteralField(item, typeof<int>, value)
|
||||
if key = "id" then idLookup.[item] <- plf
|
||||
group.AddMember plf
|
||||
|
||||
resourceType.AddMember group
|
||||
Some(resourceType, idLookup)
|
||||
| _ -> None
|
||||
generatedResource
|
||||
|
||||
let buildTypes typeName (parameterValues: obj []) =
|
||||
let xn = XName.op_Implicit
|
||||
let designerFile = parameterValues.[0] :?> string
|
||||
|
||||
let foundFiles =
|
||||
Directory.EnumerateFiles(config.ResolutionFolder, designerFile, SearchOption.AllDirectories)
|
||||
|
||||
let rec procesElements (elements:XElement seq) =
|
||||
[
|
||||
for element in elements do
|
||||
|
||||
let attrib = element.Attribute( XName.Get("id", "http://schemas.android.com/apk/res/android")) |> Option.ofObj
|
||||
match attrib with
|
||||
| Some(id) ->
|
||||
let children = procesElements (element.Elements())
|
||||
yield { ElementName = element.Name.LocalName
|
||||
Id = cleanupId id.Value
|
||||
Children = children }
|
||||
| None ->
|
||||
() ]
|
||||
|
||||
let scenes =
|
||||
[ for designerFile in foundFiles do
|
||||
|
||||
let xdoc, watcherDisposer =
|
||||
use sr = new StreamReader(designerFile, true)
|
||||
let xdoc = XDocument.Load(sr)
|
||||
xdoc, File.watch designerFile this.Invalidate
|
||||
|
||||
let processedElements = procesElements (xdoc.Root.Elements())
|
||||
let sceneModel = {FileName=designerFile;Elements=processedElements}
|
||||
watchedFiles.Add watcherDisposer
|
||||
|
||||
yield sceneModel ]
|
||||
|
||||
let propertyGetterCode (resourceModel: (ProvidedTypeDefinition * Dictionary<string,ProvidedLiteralField>) option) fieldinfo key (parameters : Expr list) =
|
||||
|
||||
let instance = parameters.[0]
|
||||
|
||||
let literalField =
|
||||
match resourceModel with
|
||||
| Some(ptd, resources) ->
|
||||
match resources.TryGetValue key with
|
||||
| true, v -> v
|
||||
| false, _ -> failwith "Could not find matching resource model"
|
||||
| None _ -> failwith "Could not find matching resource model"
|
||||
|
||||
let propexpr =
|
||||
let field = Expr.FieldGet(instance ,fieldinfo)
|
||||
let mi = match <@ Reflection.lazyFieldGen (<@()@>, <@()@>, null, null) @> with Patterns.Call(_,mi,_) -> mi | q -> failwithf "Could not find method for %A" q
|
||||
let gmethodDef = mi.GetGenericMethodDefinition()
|
||||
let gmethod = gmethodDef.MakeGenericMethod(fieldinfo.FieldType)
|
||||
gmethod.Invoke(null, [|instance; field; fieldinfo; literalField|]) :?> Expr
|
||||
|
||||
//let method' = typeof<Reflection>.GetMethod("lazyFieldGen", BindingFlags.PublicStatic).GetGenericMethodDefinition()
|
||||
//let gmethod = method'.MakeGenericMethod(fieldinfo.FieldType)
|
||||
//gmethod.Invoke(null, [|instance;field;fieldinfo;literalField|]) :?> Expr
|
||||
|
||||
propexpr
|
||||
|
||||
let generatedCodeAttribute = mkGeneratedCodeAttribute "Xamarin.Android.UIProvider" "0.1"
|
||||
|
||||
let createUIMembers resourceModel (model:Model) =
|
||||
let registerAttrib, mappedType = androidTypeMap.[model.MappingName]
|
||||
|
||||
let field = ProvidedField("_" + model.Id, mappedType)
|
||||
field.AddCustomAttribute generatedCodeAttribute
|
||||
|
||||
let prop = ProvidedProperty(model.Id, mappedType, GetterCode = (propertyGetterCode resourceModel field model.Id))
|
||||
prop.AddCustomAttribute generatedCodeAttribute
|
||||
[field :> MemberInfo
|
||||
prop :> _ ]
|
||||
|
||||
let resourceModel =
|
||||
match Directory.EnumerateFiles(config.ResolutionFolder, "R.java", SearchOption.AllDirectories) |> Seq.tryHead with
|
||||
| Some file -> getResourceModel file
|
||||
| _ -> failwithf "Java resource file not found in resolution folder path: %s" config.ResolutionFolder
|
||||
|
||||
|
||||
|
||||
let providedElements =
|
||||
let rec loop (model:Model) =
|
||||
[yield! createUIMembers resourceModel model
|
||||
for child in model.Children do
|
||||
yield! loop child ]
|
||||
|
||||
[for scene in scenes do
|
||||
for model in scene.Elements do
|
||||
yield! loop model ]
|
||||
|
||||
//create a container to store types
|
||||
let container = ProvidedTypeDefinition(asm, ns, typeName, Some(typeof<'T>), IsErased=false)
|
||||
container.SetAttributes (TypeAttributes.Abstract ||| TypeAttributes.Public)
|
||||
container.AddMembers providedElements
|
||||
|
||||
resourceModel |> Option.iter (fst >> container.AddMember)
|
||||
|
||||
let addDefaultCtor (t:ProvidedTypeDefinition) =
|
||||
let defaultCtor = ProvidedConstructor([], InvokeCode=fun _ -> <@@ () @@>)
|
||||
t.AddMember defaultCtor
|
||||
|
||||
match typeof<'T> with
|
||||
| t when t = typeof<Android.App.Fragment> -> addDefaultCtor container
|
||||
| t when t = typeof<Android.App.Activity> -> addDefaultCtor container
|
||||
| t when t = typeof<Android.Views.View> ->
|
||||
let viewType = typeof<Android.Views.View>
|
||||
|
||||
let contextType = typeof<Android.Content.Context>
|
||||
let baseCtor = viewType.GetConstructor(BindingFlags.All, Type.DefaultBinder, [|contextType|], [||] )
|
||||
let ctor = ProvidedConstructor([ProvidedParameter( "context", contextType)]){
|
||||
baseConstructorCall (fun args -> baseCtor, args)
|
||||
invokeCode (fun _ -> <@@ () @@> ) }
|
||||
|
||||
let attrType = typeof<Android.Util.IAttributeSet>
|
||||
let baseCtor2 = viewType.GetConstructor(BindingFlags.All, Type.DefaultBinder, [|contextType; attrType|], [||] )
|
||||
let ctor2 = ProvidedConstructor([ProvidedParameter( "context", contextType)
|
||||
ProvidedParameter( "attrs", attrType)]){
|
||||
baseConstructorCall (fun args -> baseCtor2, args)
|
||||
invokeCode (fun _ -> <@@ () @@> ) }
|
||||
|
||||
container.AddMembers [ctor;ctor2]
|
||||
| other -> failwithf "Unknown type %A" other
|
||||
|
||||
//pump types into the correct assembly
|
||||
let assembly = ProvidedAssembly(Path.ChangeExtension(Path.GetTempFileName(), ".dll"))
|
||||
assembly.AddTypes [container]
|
||||
container
|
||||
|
||||
let axmlFilesParam =
|
||||
let param = ProvidedStaticParameter("axml", typeof<string>)
|
||||
param.AddXmlDoc "The axml designer file you wish to create types for"
|
||||
param
|
||||
|
||||
do rootType.DefineStaticParameters([axmlFilesParam], buildTypes)
|
||||
this.AddNamespace(ns, [rootType])
|
||||
this.Disposing.Add (fun _ -> for disposer in watchedFiles do disposer.Dispose ())
|
||||
|
||||
[<TypeProvider>]
|
||||
type AndroidFragmentUIProvider(config: TypeProviderConfig) =
|
||||
inherit AndroidDesignerProvider<Android.App.Fragment>(config, "Xamarin.Android", "FragmentUI")
|
||||
|
||||
[<TypeProvider>]
|
||||
type AndroidViewUIProvider(config: TypeProviderConfig) =
|
||||
inherit AndroidDesignerProvider<Android.Views.View>(config, "Xamarin.Android", "ViewUI")
|
||||
|
||||
[<TypeProvider>]
|
||||
type AndroidActivityUIProvider(config: TypeProviderConfig) =
|
||||
inherit AndroidDesignerProvider<Android.App.Activity>(config, "Xamarin.Android", "ActivityUI")
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
namespace Xamarin.Android.UIProvider
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open System.IO
|
||||
open System.Reflection
|
||||
open System.Text
|
||||
open System.Text.RegularExpressions
|
||||
|
||||
|
||||
module Resources =
|
||||
type Id = {Name:string; Id:int}
|
||||
type ResourceModel = Dictionary<string, Id list>
|
||||
type State =
|
||||
{HasMainResource:bool; CurrentType: string option; Model : ResourceModel option}
|
||||
static member Empty = {HasMainResource=false;CurrentType=None; Model=None}
|
||||
let (|GetName|) (name:string) =
|
||||
match name with
|
||||
| "anim" -> "Animation"
|
||||
| "attr" -> "Attribute"
|
||||
| "bool" -> "Boolean"
|
||||
| "dimen" -> "Dimension"
|
||||
| other -> string (Char.ToUpperInvariant (name.[0])) + name.[1..]
|
||||
|
||||
let (|CompiledMatch|_|) pattern input =
|
||||
if input = null then None else
|
||||
let m = Regex.Match(input, pattern, RegexOptions.Compiled)
|
||||
if m.Success then
|
||||
Some [for x in m.Groups do if x.Success then yield x]
|
||||
else None
|
||||
|
||||
let (|Resource|_|) = (|CompiledMatch|_|) "^public final class R {"
|
||||
|
||||
let (|Type|_|) = function
|
||||
| CompiledMatch "^ public static final class ([^ ]+) {$" group ->
|
||||
match group with
|
||||
| [_line;typ] when not (String.IsNullOrEmpty typ.Value) -> Some(typ.Value)
|
||||
| _ -> None
|
||||
| _ -> None
|
||||
|
||||
let (|Id|_|) = function
|
||||
| CompiledMatch @"^ public static final int ([^ =]+)\s*=\s*([^;]+);$" group ->
|
||||
match group with
|
||||
| [_line; name; id] when
|
||||
not (String.IsNullOrEmpty name.Value) &&
|
||||
not (String.IsNullOrEmpty id.Value) -> Some(name.Value, id.Value)
|
||||
| _ -> None
|
||||
| _ -> None
|
||||
|
||||
let private foldModel state line =
|
||||
match line with
|
||||
| Resource _group -> {state with HasMainResource=true}
|
||||
| Type typ when state.HasMainResource -> {state with CurrentType = Some(typ)}
|
||||
| Id (name, value) ->
|
||||
match state with
|
||||
| { HasMainResource = true; CurrentType = Some(typ) } ->
|
||||
let model = match state.Model with Some(m) -> m | _ -> ResourceModel()
|
||||
match model.TryGetValue typ with
|
||||
| true, v ->
|
||||
model.Remove(typ) |> ignore
|
||||
model.Add(typ, {Name=name; Id=int value} :: v)
|
||||
| false, _ -> model.Add(typ, [{Name=name;Id=int value}])
|
||||
{state with Model = Some(model)}
|
||||
| _ -> state
|
||||
| _ -> state
|
||||
|
||||
let getModel filename =
|
||||
File.ReadLines(filename)
|
||||
|> Seq.fold foldModel State.Empty
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
Images, layout descriptions, binary blobs and string dictionaries can be included
|
||||
in your application as resource files. Various Android APIs are designed to
|
||||
operate on the resource IDs instead of dealing with images, strings or binary blobs
|
||||
directly.
|
||||
|
||||
For example, a sample Android app that contains a user interface layout (main.axml),
|
||||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
|
||||
would keep its resources in the "Resources" directory of the application:
|
||||
|
||||
Resources/
|
||||
drawable/
|
||||
icon.png
|
||||
|
||||
layout/
|
||||
main.axml
|
||||
|
||||
values/
|
||||
strings.xml
|
||||
|
||||
In order to get the build system to recognize Android resources, set the build action to
|
||||
"AndroidResource". The native Android APIs do not operate directly with filenames, but
|
||||
instead operate on resource IDs. When you compile an Android application that uses resources,
|
||||
the build system will package the resources for distribution and generate a class called "R"
|
||||
(this is an Android convention) that contains the tokens for each one of the resources
|
||||
included. For example, for the above Resources layout, this is what the R class would expose:
|
||||
|
||||
public class R {
|
||||
public class drawable {
|
||||
public const int icon = 0x123;
|
||||
}
|
||||
|
||||
public class layout {
|
||||
public const int main = 0x456;
|
||||
}
|
||||
|
||||
public class strings {
|
||||
public const int first_string = 0xabc;
|
||||
public const int second_string = 0xbcd;
|
||||
}
|
||||
}
|
||||
|
||||
You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main
|
||||
to reference the layout/main.axml file, or R.strings.first_string to reference the first
|
||||
string in the dictionary file values/strings.xml.
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version: 4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace global
|
||||
|
||||
[<assembly: Android.Runtime.ResourceDesignerAttribute("Xamarin.Android.UIProvider.Resource", IsApplication=false)>]
|
||||
do ()
|
||||
namespace Xamarin.Android.UIProvider
|
||||
// Generated by F# CodeDom
|
||||
#nowarn "49" // uppercase argument names
|
||||
#nowarn "67" // this type test or downcast will always hold
|
||||
#nowarn "66" // this upcast is unnecessary - the types are identical
|
||||
#nowarn "58" // possible incorrect indentation..
|
||||
#nowarn "57" // do not use create_DelegateEvent
|
||||
#nowarn "51" // address-of operator can occur in the code
|
||||
#nowarn "1183" // unused 'this' reference
|
||||
|
||||
exception ReturnException5b9201a06adc4fa7891feaee14a489e7 of obj
|
||||
exception ReturnNoneException5b9201a06adc4fa7891feaee14a489e7
|
||||
[<AutoOpen>]
|
||||
module FuncConvertFinalOverload5b9201a06adc4fa7891feaee14a489e7 =
|
||||
// This extension member adds to the FuncConvert type and is the last resort member in the method overloading rules.
|
||||
type global.Microsoft.FSharp.Core.FuncConvert with
|
||||
/// A utility function to convert function values from tupled to curried form
|
||||
static member FuncFromTupled (f:'T -> 'Res) = f
|
||||
|
||||
type
|
||||
[<System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")>]
|
||||
|
||||
(* partial *)Resource () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
|
||||
|
||||
|
||||
and
|
||||
|
||||
(* partial *)Resource_Attribute () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
|
||||
|
||||
|
||||
and
|
||||
|
||||
(* partial *)Resource_String () =
|
||||
static do Android.Runtime.ResourceIdManager.UpdateIdValues()
|
||||
// aapt resource value: 0x7f020000
|
||||
[<Microsoft.FSharp.Core.DefaultValueAttribute(false)>]
|
||||
static val mutable private library_name:int
|
||||
(* Member of type 'CodeTypeConstructor' is not supported by the CodeDOM provider and was omitted *)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string
|
||||
name="library_name">Xamarin.Android.UIPRovider</string>
|
||||
</resources>
|
|
@ -0,0 +1,62 @@
|
|||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Xamarin.Android.UIProvider</RootNamespace>
|
||||
<AssemblyName>Xamarin.Android.UIProvider</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<PlatformTarget></PlatformTarget>
|
||||
<CustomCommands>
|
||||
<CustomCommands>
|
||||
<Command type="Execute" command="/Users/dave/code/xamarin/monodevelop/main/build/bin/MonoDevelop.exe --no-redirect" workingdir="/Users/dave/code/xamarin/monodevelop/main/build/bin/" />
|
||||
</CustomCommands>
|
||||
</CustomCommands>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<GenerateTailCalls>true</GenerateTailCalls>
|
||||
<PlatformTarget></PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Mono.Android">
|
||||
<HintPath>\Library\Frameworks\Xamarin.Android.framework\Versions\Current\lib\xbuild-frameworks\MonoAndroid\v5.0\Mono.Android.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="Java.Interop">
|
||||
<HintPath>..\..\..\..\..\Library\Frameworks\Xamarin.Android.framework\Versions\6.1.99-76\lib\xbuild-frameworks\MonoAndroid\v1.0\Java.Interop.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ExtCore">
|
||||
<HintPath>..\packages\ExtCore.0.8.45\lib\net45\ExtCore.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ProvidedTypes.fsi" />
|
||||
<Compile Include="ProvidedTypes.fs" />
|
||||
<Compile Include="DebugProvidedTypes.fs" />
|
||||
<Compile Include="ResourceGeneration.fs" />
|
||||
<Compile Include="Provider.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" />
|
||||
</Project>
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "Xamarin.Android.UIPRovider", "Xamarin.Android.UIPRovider.fsproj", "{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BDF5D89F-10DD-4232-9C5D-D1488FC3EDF8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="ExtCore" version="0.8.45" targetFramework="net45" />
|
||||
<package id="FSharp.TypeProviders.StarterPack" version="1.1.3.88" targetFramework="MonoAndroid60" />
|
||||
</packages>
|
|
@ -0,0 +1,12 @@
|
|||
namespace Xamarin.Android.UIProvider.Runtime
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
|
||||
//type WrappedView =
|
||||
// inherit Android.Views.View
|
||||
// new() = { inherit Android.Views.View(null) }
|
||||
// new(context) = { inherit Android.Views.View(context) }
|
||||
// new(context:Android.Content.Context, attrs) = { inherit Android.Views.View(context, attrs) }
|
||||
// new(context, attrs, defStyle) = { inherit Android.Views.View(context, attrs, defStyle) }
|
||||
|
||||
[<assembly:TypeProviderAssembly("Xamarin.Android.UIProvider")>]
|
||||
()
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3AAE14BD-F10D-44C0-A09C-685C95B52646}</ProjectGuid>
|
||||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Xamarin.Android.UIProvider.Runtime</RootNamespace>
|
||||
<AssemblyName>Xamarin.Android.UIProvider.Runtime</AssemblyName>
|
||||
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
|
||||
<AndroidResgenFile>Resources\Resource.designer.fs</AndroidResgenFile>
|
||||
<AndroidResgenClass>Resource</AndroidResgenClass>
|
||||
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
|
||||
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
|
||||
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AndroidLinkMode>None</AndroidLinkMode>
|
||||
<PlatformTarget></PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
|
||||
<GenerateTailCalls>true</GenerateTailCalls>
|
||||
<PlatformTarget></PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="FSharp.Core" />
|
||||
<Reference Include="Mono.Android" />
|
||||
<Reference Include="Java.Interop">
|
||||
<HintPath>..\..\..\..\..\Library\Frameworks\Xamarin.Android.framework\Versions\6.1.99-76\lib\xbuild-frameworks\MonoAndroid\v1.0\Java.Interop.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Provider.fs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.FSharp.targets" />
|
||||
</Project>
|