Skip to content

2.3.0版本升级后,发生System.NullReferenceException异常 #305

@dxc272

Description

@dxc272

【ITestService.cs】

namespace WebApplication
{
	public interface ITestService
	{
		void Update((string a, string b, string c, string d, string e, string f, string g, string h) tupleKey);
	}
}

【TestService.cs】

namespace WebApplication
{
	public class TestService : ITestService
	{
		public void Update((string a, string b, string c, string d, string e, string f, string g, string h) tupleKey)
		{
		}
	}
}

【Program.cs】

namespace WebApplication
{
	public class Program
	{
		public static void Main(string[] args)
		{
			var builder = WebApplication.CreateBuilder(args);
			builder.Services.AddControllers();
			builder.Services.AddEndpointsApiExplorer();
			builder.Services.AddSwaggerGen();
			builder.Services.AddScoped<ITestService, TestService>();
			//↓mark1
			builder.Host.UseDynamicProxy();
			//↓mark2
			var app = builder.Build();
			app.MapControllers();
			app.Run();
		}
	}
}

.net6.0下,在该包升级到2.3.0版本后,当依赖注入的接口中的方法参数是元组,且元组的元素个数大于7个的时候,在上记代码块mark2处会报System.NullReferenceException异常。内部报错的地方是src/AspectCore.Extensions.Reflection/Emit/ILGeneratorExtensions.cs 的EmitArray方法内

在2.3.0之前的版本没有这个问题,当方法参数中元组的元素个数≤7时也没有这个问题。由于取元组第8个元素需要通过Rest属性嵌套取,因此感觉是2.3.0版本在取元组第8个元素时取不到值为null,在GetType()时发生该异常。

由于项目中目前正在使用该包并想升级到最新版,希望有时间的话可以得到确认,如果是2.3.0版本的问题的话希望得到修正。
不胜感激。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions