Skip to content

Commit 93e20a0

Browse files
authored
Merge pull request #665 from stakx/bug/by-ref-like-parameters
Prevent disallowed conversions between `object` and by-ref-like parameter and return types
2 parents cc89d52 + 1398959 commit 93e20a0

File tree

9 files changed

+600
-33
lines changed

9 files changed

+600
-33
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
Enhancements:
66
- Now target frameworks are: .NET 8, .NET Framework 4.6.2, .NET Standard 2.0
77
- Tests platforms now are: .NET Framework 4.6.2, .NET 8, .NET 9
8+
- Minimally improved support for methods having `ref struct` parameter and return types, such as `Span<T>`: Intercepting such methods caused the runtime to throw `InvalidProgramException` and `NullReferenceException` due to forbidden conversions of `ref struct` values when transferring them into & out of `IInvocation` instances. To prevent these exceptions from being thrown, such values now get replaced with `null` in `IInvocation`, and with `default` values in return values and `out` arguments. When proceeding to a target, the target methods likewise receive such nullified values. (@stakx, #665)
89
- Dependencies were updated
910

11+
Bugfixes:
12+
- `InvalidProgramException` when proxying `MemoryStream` with .NET 7 (@stakx, #651)
13+
1014
Deprecations:
1115
- .NET Core 2.1, .NET Core 3.1, .NET 6, and mono tests
1216
- .NET Standard 2.1 tfm

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@ build.cmd
5050

5151
The following conditional compilation symbols (vertical) are currently defined for each of the build configurations (horizontal):
5252

53-
Symbol | .NET 4.6.2 | .NET Standard 2.x and .NET 8+
54-
----------------------------------- | ------------------ | -----------------------------
55-
`FEATURE_APPDOMAIN` | :white_check_mark: | :no_entry_sign:
56-
`FEATURE_ASSEMBLYBUILDER_SAVE` | :white_check_mark: | :no_entry_sign:
57-
`FEATURE_SERIALIZATION` | :white_check_mark: | :no_entry_sign:
58-
`FEATURE_SYSTEM_CONFIGURATION` | :white_check_mark: | :no_entry_sign:
53+
Symbol | .NET 4.6.2 | .NET Standard 2.0 | .NET 8
54+
----------------------------------- | ------------------ | ----------------- | ------------------
55+
`FEATURE_APPDOMAIN` | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
56+
`FEATURE_ASSEMBLYBUILDER_SAVE` | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
57+
`FEATURE_BYREFLIKE` | :no_entry_sign: | :no_entry_sign: | :white_check_mark:
58+
`FEATURE_SERIALIZATION` | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
59+
`FEATURE_SYSTEM_CONFIGURATION` | :white_check_mark: | :no_entry_sign: | :no_entry_sign:
5960

6061
* `FEATURE_APPDOMAIN` - enables support for features that make use of an AppDomain in the host.
6162
* `FEATURE_ASSEMBLYBUILDER_SAVE` - enabled support for saving the dynamically generated proxy assembly.
63+
* `FEATURE_BYREFLIKE` - enables support for by-ref-like (`ref struct`) types such as `Span<T>` and `ReadOnlySpan<T>`.
6264
* `FEATURE_SERIALIZATION` - enables support for serialization of dynamic proxies and other types.
6365
* `FEATURE_SYSTEM_CONFIGURATION` - enables features that use System.Configuration and the ConfigurationManager.

buildscripts/common.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
<DefineConstants>$(NetStandard20Constants)</DefineConstants>
6767
</PropertyGroup>
6868

69+
<PropertyGroup Condition="'$(TargetFramework)'=='net8.0' Or '$(TargetFramework)'=='net9.0'">
70+
<DefineConstants>$(DefineConstants);FEATURE_BYREFLIKE</DefineConstants>
71+
</PropertyGroup>
72+
6973
<ItemGroup>
7074
<None Include="$(SolutionDir)docs\images\castle-logo.png" Pack="true" PackagePath=""/>
7175
</ItemGroup>

0 commit comments

Comments
 (0)