Skip to content

Reference assembly/reflection mismatch #120

@lewisfm

Description

@lewisfm

I recently tried to generate bindings for a library that uses System.Linq.Expressions. However, Beyond.NET generated wrappers for several properties which are included in the runtime and technically public, but not included in the reference assembly.

For example, it tried to generate a wrapper for LambdaExpression.CanCompileToIL, which is defined like this in the System.Linq.Expressions source code:

[FeatureGuard(typeof(RequiresDynamicCodeAttribute))]
public static bool CanCompileToIL => RuntimeFeature.IsDynamicCodeSupported;

But it's not included in the corresponding reference assembly. So, the wrapper fails to compile with the following error:

error CS0117: 'LambdaExpression' does not contain a definition for 'CanCompileToIL'
Generated code
internal unsafe class System_Linq_Expressions_LambdaExpression
{
	[UnmanagedCallersOnly(EntryPoint = "System_Linq_Expressions_LambdaExpression_CanCompileToIL_Get")]
	internal static byte /* System.Boolean */ System_Linq_Expressions_LambdaExpression_CanCompileToIL_Get(void** /* System.Exception */ __outException)
	{
	
	    try {
			System.Boolean __returnValue = System.Linq.Expressions.LambdaExpression.CanCompileToIL;
			byte __returnValueNative = __returnValue.ToCBool();
	
	        if (__outException is not null) {
	            *__outException = null;
	        }
	
			return __returnValueNative;
	    } catch (Exception __exception) {
	        if (__outException is not null) {
	            void* __exceptionHandleAddress = __exception.AllocateGCHandleAndGetAddress();
	
	            *__outException = __exceptionHandleAddress;
	        }
	
			return 0;
		} finally {
		}
	}
}

Attempting to exclude this type via the JSON config file causes an early error in Beyond.NET.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions