Skip to content

Commit d63cb62

Browse files
YairHalberstadtslozier
authored andcommitted
Support for .Net Standard (#599)
* Support .Net Standard * Update DocBuilder.cs
1 parent 78442d0 commit d63cb62

16 files changed

Lines changed: 79 additions & 22 deletions

File tree

Build/netstandard2.0.props

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<IsFullFramework>false</IsFullFramework>
5+
</PropertyGroup>
6+
7+
<PropertyGroup>
8+
<Features>$(Features);FEATURE_APARTMENTSTATE</Features>
9+
<Features>$(Features);FEATURE_APPLICATIONEXCEPTION</Features>
10+
<Features>$(Features);FEATURE_ASSEMBLY_CODEBASE</Features>
11+
<Features>$(Features);FEATURE_ASSEMBLY_LOCATION</Features>
12+
<Features>$(Features);FEATURE_ASSEMBLY_RESOLVE</Features>
13+
<Features>$(Features);FEATURE_ASSEMBLYBUILDER_DEFINEDYNAMICASSEMBLY</Features>
14+
<Features>$(Features);FEATURE_BASIC_CONSOLE</Features>
15+
<Features>$(Features);FEATURE_CODEDOM</Features>
16+
<Features>$(Features);FEATURE_CONFIGURATION</Features>
17+
<Features>$(Features);FEATURE_CTYPES</Features>
18+
<Features>$(Features);FEATURE_CUSTOM_TYPE_DESCRIPTOR</Features>
19+
<Features>$(Features);FEATURE_DBNULL</Features>
20+
<Features>$(Features);FEATURE_DRIVENOTFOUNDEXCEPTION</Features>
21+
<Features>$(Features);FEATURE_DYNAMIC_EXPRESSION_VISITOR</Features>
22+
<Features>$(Features);FEATURE_ENCODING</Features>
23+
<Features>$(Features);FEATURE_EXCEPTION_STATE</Features>
24+
<Features>$(Features);FEATURE_FILESYSTEM</Features>
25+
<Features>$(Features);FEATURE_FULL_CONSOLE</Features>
26+
<Features>$(Features);FEATURE_FULL_CRYPTO</Features>
27+
<Features>$(Features);FEATURE_FULL_NET</Features>
28+
<Features>$(Features);FEATURE_ICLONEABLE</Features>
29+
<Features>$(Features);FEATURE_LCG</Features>
30+
<Features>$(Features);FEATURE_LOADWITHPARTIALNAME</Features>
31+
<Features>$(Features);FEATURE_METADATA_READER</Features>
32+
<Features>$(Features);FEATURE_MMAP</Features>
33+
<Features>$(Features);FEATURE_NATIVE</Features>
34+
<Features>$(Features);FEATURE_OS_SERVICEPACK</Features>
35+
<Features>$(Features);FEATURE_PIPES</Features>
36+
<Features>$(Features);FEATURE_PROCESS</Features>
37+
<Features>$(Features);FEATURE_REFEMIT</Features>
38+
<Features>$(Features);FEATURE_REGISTRY</Features>
39+
<Features>$(Features);FEATURE_SECURITY_RULES</Features>
40+
<Features>$(Features);FEATURE_SERIALIZATION</Features>
41+
<Features>$(Features);FEATURE_SORTKEY</Features>
42+
<Features>$(Features);FEATURE_STACK_TRACE</Features>
43+
<Features>$(Features);FEATURE_SYNC_SOCKETS</Features>
44+
<Features>$(Features);FEATURE_THREAD</Features>
45+
<Features>$(Features);FEATURE_TYPE_EQUIVALENCE</Features>
46+
<Features>$(Features);FEATURE_TYPECONVERTER</Features>
47+
<Features>$(Features);FEATURE_WARNING_EXCEPTION</Features>
48+
<Features>$(Features);FEATURE_WIN32EXCEPTION</Features>
49+
<Features>$(Features);FEATURE_XMLDOC</Features>
50+
</PropertyGroup>
51+
</Project>

IronPython.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{17737ACB
4343
Build\net45.props = Build\net45.props
4444
Build\netcoreapp2.0.props = Build\netcoreapp2.0.props
4545
Build\netcoreapp2.1.props = Build\netcoreapp2.1.props
46+
Build\netstandard2.0.props = Build\netstandard2.0.props
4647
EndProjectSection
4748
EndProject
4849
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IronPythonCompiler", "Src\IronPythonCompiler\IronPythonCompiler.csproj", "{3DFB096E-AC09-4E7A-9288-7F7C33C288C7}"

Package/nuget/IronPython.nuspec

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<dependency id="Microsoft.Win32.Registry" version="4.5.0" />
2828
<dependency id="DynamicLanguageRuntime" version="[1.2.2]" />
2929
</group>
30+
<group targetFramework="netstandard2.0">
31+
<dependency id="System.Text.Encoding.CodePages" version="4.5.0" />
32+
<dependency id="Microsoft.Win32.Registry" version="4.5.0" />
33+
<dependency id="DynamicLanguageRuntime" version="[1.2.2]" />
34+
</group>
3035
</dependencies>
3136
</metadata>
3237
<files>

Src/IronPython.Modules/IronPython.Modules.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net45;netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
4+
<TargetFrameworks>net45;netcoreapp2.0;netcoreapp2.1;netstandard2.0</TargetFrameworks>
55
<BaseAddress>885063680</BaseAddress>
66
<CodeAnalysisRuleSet>$(AssemblyName).ruleset</CodeAnalysisRuleSet>
77
<DocumentationFile>$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Mono.Posix" Version="5.4.0.201" Condition=" '$(Mono)' != 'true' " />
1515
</ItemGroup>
1616
<ItemGroup>
17-
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" Condition=" '$(TargetFramework)' == 'netcoreapp2.0' OR '$(TargetFramework)' == 'netcoreapp2.1' " />
17+
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" Condition=" '$(TargetFramework)' == 'netcoreapp2.0' OR '$(TargetFramework)' == 'netcoreapp2.1' OR '$(TargetFramework)' == 'netstandard2.0' " />
1818
</ItemGroup>
1919

2020
<ItemGroup>
@@ -25,7 +25,7 @@
2525
<None Include="IronPython.Modules.ruleset" />
2626
</ItemGroup>
2727

28-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' OR '$(TargetFramework)' == 'netcoreapp2.1' ">
28+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' OR '$(TargetFramework)' == 'netcoreapp2.1' OR '$(TargetFramework)' == 'netstandard2.0' ">
2929
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
3030
</ItemGroup>
3131

Src/IronPython.Modules/_ctypes/CFuncPtr.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ private INativeType GetNativeReturnType() {
660660
}
661661

662662
private static SignatureHelper GetMethodSigHelper(CallingConvention convention, Type calliRetType) {
663-
#if NETCOREAPP2_0 || NETCOREAPP2_1
663+
#if NETCOREAPP2_0 || NETCOREAPP2_1 || NETSTANDARD2_0
664664
var helper = typeof(SignatureHelper).GetMethod("GetMethodSigHelper", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(CallingConvention), typeof(Type) }, null);
665665
return (SignatureHelper)helper.Invoke(null, new object[] { convention, calliRetType });
666666
#else

Src/IronPython.Modules/_ctypes/_ctypes.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ private static ModuleBuilder DynamicModule {
499499
if (_dynamicModule == null) {
500500
var attributes = new[] {
501501
new CustomAttributeBuilder(typeof(UnverifiableCodeAttribute).GetConstructor(ReflectionUtils.EmptyTypes), new object[0]),
502-
#if !NETCOREAPP2_0 && !NETCOREAPP2_1
502+
#if !NETCOREAPP2_0 && !NETCOREAPP2_1 && !NETSTANDARD2_0
503503
//PermissionSet(SecurityAction.Demand, Unrestricted = true)
504504
new CustomAttributeBuilder(typeof(PermissionSetAttribute).GetConstructor(new Type[] { typeof(SecurityAction) }),
505505
new object[]{ SecurityAction.Demand },
@@ -510,7 +510,7 @@ private static ModuleBuilder DynamicModule {
510510
};
511511

512512
string name = typeof(CTypes).Namespace + ".DynamicAssembly";
513-
#if NETCOREAPP2_0 || NETCOREAPP2_1
513+
#if NETCOREAPP2_0 || NETCOREAPP2_1 || NETSTANDARD2_0
514514
var assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(name), AssemblyBuilderAccess.Run, attributes);
515515
#else
516516
var assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(name), AssemblyBuilderAccess.Run, attributes);
@@ -553,7 +553,7 @@ private static ModuleBuilder DynamicModule {
553553
sizeRemaining--;
554554
}
555555

556-
_nativeTypes[size] = res = tb.CreateType();
556+
_nativeTypes[size] = res = tb.CreateTypeInfo();
557557
}
558558

559559
return res;

Src/IronPython.Modules/nt.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public static string getcwdu(CodeContext/*!*/ context) {
275275
return context.LanguageContext.DomainManager.Platform.CurrentDirectory;
276276
}
277277

278-
#if NETCOREAPP2_0 || NETCOREAPP2_1
278+
#if NETCOREAPP2_0 || NETCOREAPP2_1 || NETSTANDARD2_0
279279
private static readonly char[] invalidPathChars = new char[] { '\"', '<', '>' };
280280
#endif
281281

@@ -316,7 +316,7 @@ public static string _getfullpathname(CodeContext/*!*/ context, [NotNull]string/
316316
newdir = newdir.Replace(c, Char.MaxValue);
317317
}
318318

319-
#if NETCOREAPP2_0 || NETCOREAPP2_1
319+
#if NETCOREAPP2_0 || NETCOREAPP2_1 || NETSTANDARD2_0
320320
foreach (char c in invalidPathChars) {
321321
newdir = newdir.Replace(c, Char.MaxValue);
322322
}

Src/IronPython.SQLite/IronPython.SQLite.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net45;netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
4+
<TargetFrameworks>net45;netcoreapp2.0;netcoreapp2.1;netstandard2.0</TargetFrameworks>
55
<DocumentationFile>$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
66
<SQLiteCommon>SQLITE_DEBUG;TRUE;WIN32;_MSC_VER;SQLITE_ASCII;SQLITE_MEM_POOL;SQLITE_ENABLE_COLUMN_METADATA;SQLITE_OS_WIN;SQLITE_SYSTEM_MALLOC;VDBE_PROFILE_OFF</SQLiteCommon>
77
<SQLiteCommonOmit>SQLITE_OMIT_AUTHORIZATION;SQLITE_OMIT_DEPRECATED;SQLITE_OMIT_GET_TABLE;SQLITE_OMIT_INCRBLOB;SQLITE_OMIT_LOOKASIDE;SQLITE_OMIT_SHARED_CACHE;SQLITE_OMIT_UTF16;SQLITE_OMIT_WAL</SQLiteCommonOmit>

Src/IronPython/Compiler/PythonSavableScriptCode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public PythonSavableScriptCode(Expression<LookupCompilationDelegate> code, Sourc
3535
_moduleName = moduleName;
3636
}
3737

38-
#if !NETCOREAPP2_0 && !NETCOREAPP2_1
38+
#if !NETCOREAPP2_0 && !NETCOREAPP2_1 && !NETSTANDARD2_0
3939
protected override KeyValuePair<MethodBuilder, Type> CompileForSave(TypeGen typeGen) {
4040
var lambda = RewriteForSave(typeGen, _code);
4141

0 commit comments

Comments
 (0)