Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix decimal default parameters#1773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lostmsu merged 3 commits intopythonnet:masterfromfilmor:decimal-default-parameter
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,6 +113,7 @@ Instead, `PyIterable` does that.
- Unicode strings with surrogates were truncated when converting from Python
- `Reload` mode now supports generic methods (previously Python would stop seeing them after reload)
- Temporarily fixed issue resolving method overload when method signature has `out` parameters ([#1672](i1672))
- Decimal default parameters are now correctly taken into account

### Removed

Expand Down
6 changes: 1 addition & 5 deletionssrc/runtime/MethodBinder.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1072,11 +1072,7 @@ static internal class ParameterInfoExtensions
{
public static object? GetDefaultValue(this ParameterInfo parameterInfo)
{
// parameterInfo.HasDefaultValue is preferable but doesn't exist in .NET 4.0
bool hasDefaultValue = (parameterInfo.Attributes & ParameterAttributes.HasDefault) ==
ParameterAttributes.HasDefault;

if (hasDefaultValue)
if (parameterInfo.HasDefaultValue)
{
return parameterInfo.DefaultValue;
}
Expand Down
1 change: 1 addition & 0 deletionssrc/testing/Python.Test.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<NoWarn>IDE0051;IDE0060</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\runtime\Python.Runtime.csproj" />
Expand Down
5 changes: 5 additions & 0 deletionssrc/testing/methodtest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -258,6 +258,11 @@ public static int TestSingleDefaultParam(int i = 5)
return i;
}

public static decimal TestDecimalDefaultParam(decimal n = 1m)
{
return n;
}

public static int TestTwoDefaultParam(int i = 5, int j = 6)
{
return i + j;
Expand Down
6 changes: 6 additions & 0 deletionstests/test_method.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -441,6 +441,12 @@ def test_single_default_param():
assert result == 5


def test_decimal_default_param():
"""Test that decimal default parameters work."""
result = MethodTest.TestDecimalDefaultParam()
assert result == System.Decimal(1)


def test_one_arg_and_two_default_param():
"""Test void method with single ref-parameter."""
result = MethodTest.TestOneArgAndTwoDefaultParam(11)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp