Skip to content

Commit 542f7b0

Browse files
authored
Add .NET 6.0 (IronLanguages#1095)
* Add .NET 6.0 * Temporarily disable packaging * Use include-prerelease * Fix test_codecs_stdlib * Bump to preview 5 * Fix some analyzer warnings * Fix for preview 7 * Remove reference to Microsoft.Win32.Registry * Don't package net6.0 assemblies * Fix compiling * Fix EmitCalli * Fix some failures * Fix IsStaticVirtual * Revert changes to NewTypeMaker * Revert changes to .editorconfig * Revert workaround for locale bug * Add BytesLike * Re-enable test * Re-enable packaging * Use windows-2022 agent * Check prerelease in vswhere * Remove Write-Host
1 parent b10e0a6 commit 542f7b0

File tree

23 files changed

+142
-51
lines changed

23 files changed

+142
-51
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
os: [windows-latest, ubuntu-latest, macos-latest]
13+
os: [windows-2022, ubuntu-latest, macos-latest]
1414

1515
steps:
1616
- name: Install tools
@@ -31,6 +31,11 @@ jobs:
3131
uses: actions/setup-dotnet@v1
3232
with:
3333
dotnet-version: '5.0.x'
34+
- name: Setup .NET 6.0
35+
uses: actions/setup-dotnet@v1
36+
with:
37+
dotnet-version: '6.0.x'
38+
include-prerelease: true
3439
- name: Version Information
3540
run: |
3641
dotnet --info
@@ -57,3 +62,6 @@ jobs:
5762
- name: Test (net5.0)
5863
run: ./make.ps1 -frameworks net5.0 test-all
5964
shell: pwsh
65+
- name: Test (net6.0)
66+
run: ./make.ps1 -frameworks net6.0 test-all
67+
shell: pwsh

.vsts-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
displayName: Windows
77
timeoutInMinutes: 180
88
pool:
9-
vmImage: windows-latest
9+
vmImage: windows-2022
1010
steps:
1111
- template: Build/steps.yml
1212
parameters:

Build/net6.0-windows.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<PropertyGroup>
3+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
4+
<OutputPath Condition=" '$(TargetFramework)' == 'net6.0-windows' ">$(BaseOutputPath)\net6.0</OutputPath>
5+
</PropertyGroup>
6+
7+
<Import Project="net6.0.props" />
8+
</Project>

Build/net6.0.props

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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_ASSEMBLY_GETFORWARDEDTYPES</Features>
10+
<Features>$(Features);FEATURE_ASSEMBLY_RESOLVE</Features>
11+
<Features>$(Features);FEATURE_ASSEMBLYBUILDER_DEFINEDYNAMICASSEMBLY</Features>
12+
<Features>$(Features);FEATURE_BASIC_CONSOLE</Features>
13+
<Features>$(Features);FEATURE_CODEDOM</Features>
14+
<Features>$(Features);FEATURE_COM</Features>
15+
<Features>$(Features);FEATURE_CONFIGURATION</Features>
16+
<Features>$(Features);FEATURE_CTYPES</Features>
17+
<Features>$(Features);FEATURE_CUSTOM_TYPE_DESCRIPTOR</Features>
18+
<Features>$(Features);FEATURE_DYNAMIC_EXPRESSION_VISITOR</Features>
19+
<Features>$(Features);FEATURE_EXCEPTION_STATE</Features>
20+
<Features>$(Features);FEATURE_FILESYSTEM</Features>
21+
<Features>$(Features);FEATURE_FULL_CONSOLE</Features>
22+
<Features>$(Features);FEATURE_FULL_CRYPTO</Features>
23+
<Features>$(Features);FEATURE_FULL_NET</Features>
24+
<Features>$(Features);FEATURE_LCG</Features>
25+
<Features>$(Features);FEATURE_LOADWITHPARTIALNAME</Features>
26+
<Features>$(Features);FEATURE_METADATA_READER</Features>
27+
<Features>$(Features);FEATURE_MMAP</Features>
28+
<Features>$(Features);FEATURE_NATIVE</Features>
29+
<Features>$(Features);FEATURE_OSPLATFORMATTRIBUTE</Features>
30+
<Features>$(Features);FEATURE_PIPES</Features>
31+
<Features>$(Features);FEATURE_PROCESS</Features>
32+
<Features>$(Features);FEATURE_REFEMIT</Features>
33+
<Features>$(Features);FEATURE_REGISTRY</Features>
34+
<Features>$(Features);FEATURE_RUNTIMEINFORMATION</Features>
35+
<Features>$(Features);FEATURE_SECURITY_RULES</Features>
36+
<Features>$(Features);FEATURE_SERIALIZATION</Features>
37+
<Features>$(Features);FEATURE_STACK_TRACE</Features>
38+
<Features>$(Features);FEATURE_SYNC_SOCKETS</Features>
39+
<Features>$(Features);FEATURE_THREAD</Features>
40+
<Features>$(Features);FEATURE_XMLDOC</Features>
41+
</PropertyGroup>
42+
</Project>

Build/steps.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,18 @@ steps:
3737
version: '3.1.x'
3838

3939
- task: UseDotNet@2
40-
displayName: Install .NET Core 5.0 SDK for build
40+
displayName: Install .NET Core 5.0 runtime for testing
4141
inputs:
42-
packageType: 'sdk'
42+
packageType: 'runtime'
4343
version: '5.0.x'
4444

45+
- task: UseDotNet@2
46+
displayName: Install .NET Core 6.0 SDK for build
47+
inputs:
48+
packageType: 'sdk'
49+
version: '6.0.x'
50+
includePreviewVersions: true
51+
4552
# Set Mono version on macOS
4653
- ${{ if eq(parameters.os, 'macOS') }}:
4754
- task: ms-devlabs.utilitytasks.task-Shellpp.Shell++@0

Package/nuget/IronPython.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
</dependencies>
3535
</metadata>
3636
<files>
37-
<file src="**\IronPython*.dll" target="lib" exclude="**\IronPythonTest.dll;**\DLLs\*.dll;netcoreapp2.1\**\*;net5.0*\**\*" />
38-
<file src="**\IronPython*.pdb" target="lib" exclude="**\IronPythonTest.pdb;**\DLLs\*.pdb;netcoreapp2.1\**\*;net5.0*\**\*" />
39-
<file src="**\IronPython*.xml" target="lib" exclude="**\IronPythonTest.xml;**\DLLs\*.xml;netcoreapp2.1\**\*;net5.0*\**\*" />
37+
<file src="**\IronPython*.dll" target="lib" exclude="**\IronPythonTest.dll;**\DLLs\*.dll;netcoreapp2.1\**\*;net5.0*\**\*;net6.0*\**\*" />
38+
<file src="**\IronPython*.pdb" target="lib" exclude="**\IronPythonTest.pdb;**\DLLs\*.pdb;netcoreapp2.1\**\*;net5.0*\**\*;net6.0*\**\*" />
39+
<file src="**\IronPython*.xml" target="lib" exclude="**\IronPythonTest.xml;**\DLLs\*.xml;netcoreapp2.1\**\*;net5.0*\**\*;net6.0*\**\*" />
4040
<file src="LICENSE;README.md" />
4141
</files>
4242
</package>

Src/IronPython.Modules/IronPython.Modules.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>net46;netcoreapp3.1;netstandard2.0;net5.0</TargetFrameworks>
4+
<TargetFrameworks>net46;netcoreapp3.1;netstandard2.0;net5.0;net6.0</TargetFrameworks>
55
<BaseAddress>885063680</BaseAddress>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

Src/IronPython.Modules/_ctypes/CFuncPtr.cs

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,28 @@
44

55
#if FEATURE_CTYPES
66

7-
using System.Linq.Expressions;
8-
using System.Numerics;
9-
107
using System;
118
using System.Collections.Generic;
12-
using System.Dynamic;
139
using System.Diagnostics;
10+
using System.Dynamic;
11+
using System.Linq;
12+
using System.Linq.Expressions;
13+
using System.Numerics;
1414
using System.Reflection;
1515
using System.Reflection.Emit;
1616
using System.Runtime.CompilerServices;
1717
using System.Runtime.InteropServices;
1818
using System.Threading;
1919

20-
using Microsoft.Scripting;
21-
using Microsoft.Scripting.Ast;
22-
using Microsoft.Scripting.Generation;
23-
using Microsoft.Scripting.Runtime;
24-
using Microsoft.Scripting.Utils;
25-
2620
using IronPython.Runtime;
2721
using IronPython.Runtime.Binding;
2822
using IronPython.Runtime.Operations;
2923
using IronPython.Runtime.Types;
3024

25+
using Microsoft.Scripting.Ast;
26+
using Microsoft.Scripting.Generation;
27+
using Microsoft.Scripting.Runtime;
28+
3129
namespace IronPython.Modules {
3230
/// <summary>
3331
/// Provides support for interop with native code from Python code.
@@ -388,7 +386,7 @@ private Expression AddReturnChecks(CodeContext context, DynamicMetaObject[] args
388386
typeof(PythonOps).GetMethod(nameof(PythonOps.MakeTuple)),
389387
Expression.NewArrayInit(
390388
typeof(object),
391-
ArrayUtils.ConvertAll(args, x => Utils.Convert(x.Expression, typeof(object)))
389+
Microsoft.Scripting.Utils.ArrayUtils.ConvertAll(args, x => Utils.Convert(x.Expression, typeof(object)))
392390
)
393391
)
394392
);
@@ -609,7 +607,7 @@ private INativeType GetNativeReturnType() {
609607
#endif
610608

611609
method.Emit(OpCodes.Ldarg_0);
612-
method.Emit(OpCodes.Calli, GetCalliSignature(convention, sig, calliRetType));
610+
method.EmitCalli(OpCodes.Calli, convention, calliRetType, sig.Select(x => x.NativeType).ToArray());
613611

614612
// if we have a return value we need to store it and marshal to Python
615613
// before we run any cleanup code.
@@ -658,25 +656,6 @@ private INativeType GetNativeReturnType() {
658656
#endif
659657
}
660658

661-
private static SignatureHelper GetMethodSigHelper(CallingConvention convention, Type calliRetType) {
662-
#if FEATURE_REFEMIT_FULL
663-
return SignatureHelper.GetMethodSigHelper(convention, calliRetType);
664-
#else
665-
var helper = typeof(SignatureHelper).GetMethod("GetMethodSigHelper", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(CallingConvention), typeof(Type) }, null);
666-
return (SignatureHelper)helper.Invoke(null, new object[] { convention, calliRetType });
667-
#endif
668-
}
669-
670-
private static SignatureHelper GetCalliSignature(CallingConvention convention, ArgumentMarshaller/*!*/[] sig, Type calliRetType) {
671-
SignatureHelper signature = GetMethodSigHelper(convention, calliRetType);
672-
673-
foreach (ArgumentMarshaller argMarshaller in sig) {
674-
signature.AddArgument(argMarshaller.NativeType);
675-
}
676-
677-
return signature;
678-
}
679-
680659
#region Argument Marshalling
681660

682661
/// <summary>
@@ -960,6 +939,19 @@ public string __repr__(CodeContext context) {
960939
}
961940
}
962941
}
942+
943+
#if NETSTANDARD2_0
944+
#nullable enable
945+
internal static class ILGeneratorExtensions {
946+
private static MethodInfo? EmitCalliMethodInfo = typeof(ILGenerator).GetMethod("EmitCalli", new Type[] { typeof(OpCode), typeof(CallingConvention), typeof(Type), typeof(Type[]) });
947+
948+
public static void EmitCalli(this ILGenerator ilgen, OpCode opcode, CallingConvention unmanagedCallConv, Type? returnType, Type[]? parameterTypes) {
949+
// should exist in runtimes of interest, but just in case, let it throw if the method doesn't exist...
950+
EmitCalliMethodInfo!.Invoke(ilgen, new object[] { opcode, unmanagedCallConv, returnType!, parameterTypes! });
951+
}
952+
}
953+
#nullable restore
954+
#endif
963955
}
964956

965957
#endif

Src/IronPython.Modules/_ssl.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,9 @@ private static X509Certificate2 ReadCertificate(CodeContext context, string file
874874
if (cert != null) {
875875
if (key != null) {
876876
try {
877+
#pragma warning disable SYSLIB0028 // Type or member is obsolete
877878
cert.PrivateKey = key;
879+
#pragma warning restore SYSLIB0028 // Type or member is obsolete
878880
} catch (CryptographicException e) {
879881
throw ErrorDecoding(context, filename, "cert and private key are incompatible", e);
880882
}

Src/IronPython.Modules/nt.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,9 +1677,13 @@ public static void unsetenv([NotNull] string varname) {
16771677
public static object urandom(int n) {
16781678
if (n < 0) throw PythonOps.ValueError("negative argument not allowed");
16791679

1680+
#if NET6_0
1681+
var data = RandomNumberGenerator.GetBytes(n);
1682+
#else
16801683
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
16811684
byte[] data = new byte[n];
16821685
rng.GetBytes(data);
1686+
#endif
16831687

16841688
return Bytes.Make(data);
16851689
}

0 commit comments

Comments
 (0)