| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,6 +113,7 @@ Instead, `PyIterable` does that. | |||
| 113 | 113 | - Unicode strings with surrogates were truncated when converting from Python | |
| 114 | 114 | - `Reload` mode now supports generic methods (previously Python would stop seeing them after reload) | |
| 115 | 115 | - Temporarily fixed issue resolving method overload when method signature has `out` parameters ([#1672](i1672)) | |
| 116 | + - Decimal default parameters are now correctly taken into account | ||
| 116 | 117 | ||
| 117 | 118 | ### Removed | |
| 118 | 119 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1072,11 +1072,7 @@ static internal class ParameterInfoExtensions | |||
| 1072 | 1072 | { | |
| 1073 | 1073 | public static object? GetDefaultValue(this ParameterInfo parameterInfo) | |
| 1074 | 1074 | { | |
| 1075 | - // parameterInfo.HasDefaultValue is preferable but doesn't exist in .NET 4.0 | ||
| 1076 | - bool hasDefaultValue = (parameterInfo.Attributes & ParameterAttributes.HasDefault) == | ||
| 1077 | - ParameterAttributes.HasDefault; | ||
| 1078 | - | ||
| 1079 | - if (hasDefaultValue) | ||
| 1075 | + if (parameterInfo.HasDefaultValue) | ||
| 1080 | 1076 | { | |
| 1081 | 1077 | return parameterInfo.DefaultValue; | |
| 1082 | 1078 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> | |
| 6 | 6 | <AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile> | |
| 7 | 7 | <SignAssembly>true</SignAssembly> | |
| 8 | + <NoWarn>IDE0051;IDE0060</NoWarn> | ||
| 8 | 9 | </PropertyGroup> | |
| 9 | 10 | <ItemGroup> | |
| 10 | 11 | <ProjectReference Include="..\runtime\Python.Runtime.csproj" /> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -258,6 +258,11 @@ public static int TestSingleDefaultParam(int i = 5) | |||
| 258 | 258 | return i; | |
| 259 | 259 | } | |
| 260 | 260 | ||
| 261 | + public static decimal TestDecimalDefaultParam(decimal n = 1m) | ||
| 262 | + { | ||
| 263 | + return n; | ||
| 264 | + } | ||
| 265 | + | ||
| 261 | 266 | public static int TestTwoDefaultParam(int i = 5, int j = 6) | |
| 262 | 267 | { | |
| 263 | 268 | return i + j; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -441,6 +441,12 @@ def test_single_default_param(): | |||
| 441 | 441 | assert result == 5 | |
| 442 | 442 | ||
| 443 | 443 | ||
| 444 | + def test_decimal_default_param(): | ||
| 445 | + """Test that decimal default parameters work.""" | ||
| 446 | + result = MethodTest.TestDecimalDefaultParam() | ||
| 447 | + assert result == System.Decimal(1) | ||
| 448 | + | ||
| 449 | + | ||
| 444 | 450 | def test_one_arg_and_two_default_param(): | |
| 445 | 451 | """Test void method with single ref-parameter.""" | |
| 446 | 452 | result = MethodTest.TestOneArgAndTwoDefaultParam(11) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments