Skip to content

Commit 883347d

Browse files
committed
Import from private repo (no history)
1 parent cb2ffcf commit 883347d

File tree

104 files changed

+7886
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+7886
-0
lines changed

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Autosave files
2+
*~
3+
4+
# build
5+
[Oo]bj/
6+
[Bb]in/
7+
packages/
8+
TestResults/
9+
10+
# globs
11+
Makefile.in
12+
*.DS_Store
13+
*.sln.cache
14+
*.suo
15+
*.cache
16+
*.pidb
17+
*.userprefs
18+
*.usertasks
19+
config.log
20+
config.make
21+
config.status
22+
aclocal.m4
23+
install-sh
24+
autom4te.cache/
25+
*.user
26+
*.tar.gz
27+
tarballs/
28+
test-results/
29+
Thumbs.db
30+
31+
# Mac bundle stuff
32+
*.dmg
33+
*.app
34+
35+
# resharper
36+
*_Resharper.*
37+
*.Resharper
38+
39+
# dotCover
40+
*.dotCover
41+
api.xml
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{8CC94A3E-B6D6-4D9D-8FCA-6CBE86B69F64}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>BindingGenerator.Core</RootNamespace>
9+
<AssemblyName>BindingGenerator.Core</AssemblyName>
10+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG;</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
<ConsolePause>false</ConsolePause>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23+
<Optimize>true</Optimize>
24+
<OutputPath>bin\Release</OutputPath>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
<ConsolePause>false</ConsolePause>
28+
</PropertyGroup>
29+
<ItemGroup>
30+
<Reference Include="System" />
31+
<Reference Include="System.Xml" />
32+
<Reference Include="System.Xml.Linq" />
33+
<Reference Include="System.ValueTuple">
34+
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\net461\System.ValueTuple.dll</HintPath>
35+
</Reference>
36+
<Reference Include="mscorlib" />
37+
</ItemGroup>
38+
<ItemGroup>
39+
<Compile Include="Properties\AssemblyInfo.cs" />
40+
<Compile Include="Logger.cs" />
41+
<Compile Include="Extensions.XObject.cs" />
42+
<Compile Include="InputDocument.cs" />
43+
<Compile Include="Extensions.XElement.cs" />
44+
<Compile Include="Extensions.HierarchyElement.cs" />
45+
<Compile Include="Report.cs" />
46+
<Compile Include="LogLevel.cs" />
47+
<Compile Include="Extensions.String.cs" />
48+
<Compile Include="Parsing\ApiClass.cs" />
49+
<Compile Include="Parsing\ApiConstructor.cs" />
50+
<Compile Include="Parsing\ApiDescriptionReader.cs" />
51+
<Compile Include="Parsing\ApiElement.cs" />
52+
<Compile Include="Parsing\ApiException.cs" />
53+
<Compile Include="Parsing\ApiField.cs" />
54+
<Compile Include="Parsing\ApiFixupApplier.cs" />
55+
<Compile Include="Parsing\ApiImplements.cs" />
56+
<Compile Include="Parsing\ApiInterface.cs" />
57+
<Compile Include="Parsing\ApiMethod.cs" />
58+
<Compile Include="Parsing\ApiMethodParameter.cs" />
59+
<Compile Include="Parsing\ApiNameSpace.cs" />
60+
<Compile Include="Parsing\ApiType.cs" />
61+
<Compile Include="Parsing\ApiTypeMember.cs" />
62+
<Compile Include="Parsing\ApiTypeParameter.cs" />
63+
<Compile Include="Parsing\ApiTypeParameterGenericConstraint.cs" />
64+
<Compile Include="Parsing\ApiTypeParameterGenericConstraints.cs" />
65+
<Compile Include="Parsing\ApiTypeParameters.cs" />
66+
<Compile Include="Parsing\ApiVisibility.cs" />
67+
<Compile Include="Generation\Generator.cs" />
68+
<Compile Include="Generation\NameTranslationProvider.cs" />
69+
<Compile Include="Generation\OutputPathProvider.cs" />
70+
<Compile Include="Generation\DefaultOutputPathProvider.cs" />
71+
<Compile Include="Generation\FilesystemPath.cs" />
72+
<Compile Include="Generation\HierarchyNamespace.cs" />
73+
<Compile Include="Generation\HierarchyElement.cs" />
74+
<Compile Include="Parsing\ApiEnum.cs" />
75+
<Compile Include="Generation\GeneratorContext.cs" />
76+
<Compile Include="Generation\Hierarchy.cs" />
77+
<Compile Include="Generation\HierarchyClass.cs" />
78+
<Compile Include="Generation\HierarchyInterface.cs" />
79+
<Compile Include="Generation\HierarchyObject.cs" />
80+
<Compile Include="Generation\HierarchyEnum.cs" />
81+
<Compile Include="Generation\HierarchyTypeMember.cs" />
82+
<Compile Include="Generation\HierarchyBase.cs" />
83+
<Compile Include="Helpers.cs" />
84+
<Compile Include="Generation\HierarchyTypeKind.cs" />
85+
<Compile Include="Generation\HierarchyField.cs" />
86+
<Compile Include="Generation\HierarchyMethod.cs" />
87+
<Compile Include="Generation\HierarchyConstructor.cs" />
88+
<Compile Include="Generation\HierarchyImplements.cs" />
89+
<Compile Include="Generation\HierarchyTypeParameter.cs" />
90+
<Compile Include="Generation\HierarchyMethodParameter.cs" />
91+
<Compile Include="Generation\HierarchyException.cs" />
92+
<Compile Include="Generation\HierarchyTypeParameterGenericConstraint.cs" />
93+
<Compile Include="Generation\HierarchyType.cs" />
94+
<Compile Include="Generation\FormattingCodeGenerator.cs" />
95+
<Compile Include="Generation\CSharp\DefaultCSharpCodeGenerator.cs" />
96+
<Compile Include="Generation\CSharp\BaseMethodCodeGenerator.cs" />
97+
<Compile Include="Generation\CSharp\BaseClassCodeGenerator.cs" />
98+
<Compile Include="Generation\CSharp\BaseEnumCodeGenerator.cs" />
99+
<Compile Include="Generation\CSharp\BaseInterfaceCodeGenerator.cs" />
100+
<Compile Include="Generation\FormattingStyle.cs" />
101+
<Compile Include="Generation\FormattingContext.cs" />
102+
<Compile Include="Generation\MethodCodeGenerator.cs" />
103+
<Compile Include="Generation\TypeMemberCodeGenerator.cs" />
104+
<Compile Include="Generation\FieldCodeGenerator.cs" />
105+
<Compile Include="Generation\InterfaceCodeGenerator.cs" />
106+
<Compile Include="Generation\ClassCodeGenerator.cs" />
107+
<Compile Include="Generation\EnumCodeGenerator.cs" />
108+
<Compile Include="Generation\Xamarin\XamarinAndroidHierarchy.cs" />
109+
<Compile Include="Generation\HierarchyInterfaceInvoker.cs" />
110+
<Compile Include="Generation\HierarchyCustomAttribute.cs" />
111+
<Compile Include="Generation\HierarchyCustomAttributeTarget.cs" />
112+
<Compile Include="Generation\HierarchyAttributeRegister.cs" />
113+
<Compile Include="Generation\HierarchyAttributeIntDefinition.cs" />
114+
<Compile Include="Generation\HierarchyAttributeObsolete.cs" />
115+
<Compile Include="Generation\HierarchyAttributeFlags.cs" />
116+
<Compile Include="Generation\HierarchyAttributeGeneratedEnum.cs" />
117+
<Compile Include="Generation\HierarchyAttributeRequiresPermission.cs" />
118+
<Compile Include="Generation\HierarchyAttributeAnnotation.cs" />
119+
<Compile Include="Generation\HierarchyAttributePreserve.cs" />
120+
<Compile Include="Generation\HierarchyAttributeNamespaceMapping.cs" />
121+
<Compile Include="Generation\HierarchyCustomAttributeGenerator.cs" />
122+
<Compile Include="Generation\HierarchyAttributeObsoleteGenerator.cs" />
123+
<Compile Include="Generation\HierarchyAttributeParameterlessGenerator.cs" />
124+
<Compile Include="Generation\HierarchyAttributeFlagsGenerator.cs" />
125+
<Compile Include="Generation\HierarchyAttributeGeneratedEnumGenerator.cs" />
126+
<Compile Include="Generation\HierarchyAttributePreserveGenerator.cs" />
127+
<Compile Include="Generation\HierarchyAttributeAnnotationGenerator.cs" />
128+
<Compile Include="Generation\HierarchyAttributeNamespaceMappingGenerator.cs" />
129+
<Compile Include="Generation\HierarchyAttributeRequiresPermissionGenerator.cs" />
130+
<Compile Include="Generation\HierarchyAttributeRegisterGenerator.cs" />
131+
<Compile Include="Generation\HierarchyAttributeIntDefinitionGenerator.cs" />
132+
</ItemGroup>
133+
<ItemGroup>
134+
<Folder Include="Parsing\" />
135+
<Folder Include="Generation\" />
136+
</ItemGroup>
137+
<ItemGroup>
138+
<None Include="packages.config" />
139+
</ItemGroup>
140+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
141+
</Project>
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//
2+
// Extensions.String.cs
3+
//
4+
// Author:
5+
// Marek Habersack <[email protected]>
6+
//
7+
// Copyright (c) 2018 Microsoft, Inc (http://microsoft.com/)
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
using System;
27+
using System.Collections.Generic;
28+
29+
using BindingGenerator.Core.Generation;
30+
31+
namespace BindingGenerator.Core
32+
{
33+
partial class Extensions
34+
{
35+
public static string GetManagedName (this HierarchyElement element, bool full = false)
36+
{
37+
if (element == null)
38+
return null;
39+
40+
string name = full ? element.FullManagedName : element.ManagedName;
41+
if (!String.IsNullOrEmpty (name))
42+
return name;
43+
44+
name = MakeManagedName (full ? element.FullName : element.Name);
45+
if (!String.IsNullOrEmpty (name))
46+
return name;
47+
48+
return null;
49+
}
50+
51+
static string MakeManagedName (string name)
52+
{
53+
if (name == null)
54+
return null;
55+
56+
if (name.Length == 0)
57+
return name;
58+
59+
string[] parts = name.Split ('.');
60+
var mangled = new List <string> ();
61+
62+
foreach (string p in parts) {
63+
if (String.IsNullOrEmpty (p))
64+
throw new InvalidOperationException ($"Unable to convert Java name '{name}' to a valid managed name: empty segments after splitting");
65+
66+
mangled.Add ($"{Char.ToUpper (p [0])}{p.Substring (1)}");
67+
}
68+
69+
return String.Join (".", mangled);
70+
}
71+
}
72+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// Extensions.String.cs
3+
//
4+
// Author:
5+
// Marek Habersack <[email protected]>
6+
//
7+
// Copyright (c) 2017 Microsoft, Inc (http://microsoft.com/)
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
using System;
27+
using System.Xml.Linq;
28+
29+
namespace BindingGenerator.Core
30+
{
31+
partial class Extensions
32+
{
33+
public static bool AsBool (this string v, XObject xmlObject = null)
34+
{
35+
v = v?.Trim ();
36+
if (String.IsNullOrEmpty (v))
37+
return false;
38+
39+
bool ret;
40+
if (!Boolean.TryParse (v, out ret)) {
41+
Logger.Warning ($"Value '{v}' cannot be parsed as boolean ({xmlObject.GetLineInfo ()})");
42+
return false;
43+
}
44+
45+
return ret;
46+
}
47+
}
48+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//
2+
// Extensions.XElement.cs
3+
//
4+
// Author:
5+
// Marek Habersack <[email protected]>
6+
//
7+
// Copyright (c) 2017 Microsoft, Inc (http://microsoft.com/)
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
using System;
27+
using System.Xml.Linq;
28+
29+
namespace BindingGenerator.Core
30+
{
31+
partial class Extensions
32+
{
33+
public static string XGetAttribute (this XElement element, string name)
34+
{
35+
if (element == null)
36+
return null;
37+
38+
XAttribute attr = element.Attribute (name);
39+
return attr?.Value.Trim ();
40+
}
41+
42+
public static bool Is (this XElement element, string name)
43+
{
44+
if (element == null || String.IsNullOrEmpty (name))
45+
return false;
46+
47+
return String.Compare (name, element.Name.LocalName, StringComparison.Ordinal) == 0;
48+
}
49+
}
50+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// Extensions.XObject.cs
3+
//
4+
// Author:
5+
// Marek Habersack <[email protected]>
6+
//
7+
// Copyright (c) 2017 Microsoft, Inc (http://microsoft.com/)
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
using System;
27+
using System.Xml;
28+
using System.Xml.Linq;
29+
30+
namespace BindingGenerator.Core
31+
{
32+
static partial class Extensions
33+
{
34+
public static string GetLineInfo (this XObject obj)
35+
{
36+
var info = obj as IXmlLineInfo;
37+
if (obj == null || !info.HasLineInfo ())
38+
return "0:0";
39+
return $"{info.LineNumber}:{info.LinePosition}";
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)