Skip to content

Commit 25e66f0

Browse files
dmitriysefilmor
authored andcommitted
Binary substitution of Python.Runtime.dll becomes safe. (#456)
* Binary substitution of Python.Runtime.Dll becomes safe. * Public constants replaced to static readonly fields. Relaxed platform binding. * Static readonly fields (related to build depented values) replaced by properties.
1 parent 87eb102 commit 25e66f0

File tree

4 files changed

+291
-270
lines changed

4 files changed

+291
-270
lines changed

src/embed_tests/TestPythonEngineProperties.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void SetProgramName()
146146
[Test]
147147
public void SetPythonPath()
148148
{
149-
if (Runtime.Runtime.pyversion == "2.7")
149+
if (Runtime.Runtime._pyversion == "2.7")
150150
{
151151
// Assert.Skip outputs as a warning (ie. pending to fix)
152152
Assert.Pass();
@@ -166,7 +166,7 @@ public void SetPythonPath()
166166
[Test]
167167
public void SetPythonPathExceptionOn27()
168168
{
169-
if (Runtime.Runtime.pyversion != "2.7")
169+
if (Runtime.Runtime._pyversion != "2.7")
170170
{
171171
Assert.Pass();
172172
}

src/runtime/CustomMarshaler.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ public static int GetUnicodeByteLength(IntPtr p)
9191
var len = 0;
9292
while (true)
9393
{
94-
int c = Runtime.UCS == 2
94+
int c = Runtime._UCS == 2
9595
? Marshal.ReadInt16(p, len * 2)
9696
: Marshal.ReadInt32(p, len * 4);
9797

9898
if (c == 0)
9999
{
100-
return len * Runtime.UCS;
100+
return len * Runtime._UCS;
101101
}
102102
checked
103103
{
@@ -163,7 +163,7 @@ public override IntPtr MarshalManagedToNative(object managedObj)
163163
}
164164

165165
int totalStrLength = argv.Sum(arg => arg.Length + 1);
166-
int memSize = argv.Length * IntPtr.Size + totalStrLength * Runtime.UCS;
166+
int memSize = argv.Length * IntPtr.Size + totalStrLength * Runtime._UCS;
167167

168168
IntPtr mem = Marshal.AllocHGlobal(memSize);
169169
try

src/runtime/Python.Runtime.csproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
<SignAssembly>false</SignAssembly>
2121
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
2222
</PropertyGroup>
23-
<PropertyGroup Condition=" '$(Platform)' == 'x86'">
23+
<!--We can relax binding to platform because code references no any platform dependent assemblies-->
24+
<!--This will allows to use any build of this assebly as a compile ref assebly-->
25+
<!--<PropertyGroup Condition=" '$(Platform)' == 'x86'">
2426
<PlatformTarget>x86</PlatformTarget>
2527
</PropertyGroup>
2628
<PropertyGroup Condition=" '$(Platform)' == 'x64'">
2729
<PlatformTarget>x64</PlatformTarget>
28-
</PropertyGroup>
30+
</PropertyGroup>-->
2931
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
3032
<DefineConstants Condition="'$(DefineConstants)' == ''">PYTHON2;PYTHON27;UCS4</DefineConstants>
3133
<Optimize>true</Optimize>

0 commit comments

Comments
 (0)