如何在Visual Studio Code中按名称查找文件?
我习惯的Visual Studio快捷方式在__CODE__这里不起作用.
让我举个例子:
我有一些通用的类/接口定义:
interface IGenericCar< T > {...}
我有另一个类/接口,我想与上面的类相关,例如:
interface IGarrage< TCar > : where TCar: IGenericCar< (**any type here**) > {...}
基本上,我希望我的通用IGarrage依赖于IGenericCar,无论是否,IGenericCar<int>或者IGenericCar<System.Color>因为我对该类型没有任何依赖性.
自从更新到 Visual Studio 2019 版本16.11.0cshtml (今天)以来,Razor MVC 视图编译在多个项目中的多个文件上失败:
错误 CS1576:为 #line 指令指定的行号丢失或无效
我尝试在global.json文件中设置 .NET Core SDK 的固定版本,该文件放置在 MVC Web 项目的根文件夹中,如此处所述,但这也没有帮助。
是否简化了将list/enumberable转换KeyValuePair<T, U>为Dictionary<T, U>?
Linq转换,.ToDictionary()扩展无效.
在ASP.NET核心2.X我使用的标准路线registation Configure的方法Startup类来注册回退路线使用SPA应用MapSpaFallbackRoute扩展方法从Microsoft.AspNetCore.SpaServices.ExtensionsNuGet包:
public void Configure(IApplicationBuilder app)
{
// ...
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
}
Run Code Online (Sandbox Code Playgroud)
当使用ASP.NET Core 3.0建议UseEndpoints的端点注册扩展方法时,找不到类似的扩展方法。
在向线路写入响应流时,似乎在ASP.NET cookie处理中存在恼人的错误.Set-Cookie标题随机倍增.
我的示例设置是:IIS8 Express服务器上的ASP.NET MVC4,但在IIS7集成模式上发生同样的问题,我在2009年发现了关于同一问题IIS6的帖子.它似乎存在一段时间的问题.
例如,在Global.asax.cs中,我订阅BeginRequest事件并在事件处理程序中写入HttpResponse.Cookie集合:
public class MvcApplication : System.Web.HttpApplication
{
public override void Init()
{
base.Init();
BeginRequest += OnBeginRequest;
}
void OnBeginRequest(object sender, EventArgs e)
{
Response.Cookies.Set(new HttpCookie("OnBeginRequest", "0"));
}
}
Run Code Online (Sandbox Code Playgroud)
这将两次输出"OnBeginRequest"Set-Cookie标头.但是,如果对所有HttpApplication事件(AuthenticateRequest,AcquireRequestState等等〜总共~20个事件)进行类似操作,则发送到浏览器的http响应的头部将写入大量重复项.这也很明显,事件之后,编写cookie会从乞讨开始.
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
Set-Cookie: OnBeginRequest=0; path=/
Set-Cookie: OnBeginRequest=0; path=/
Set-Cookie: OnAuthenticateRequest=1; path=/
Set-Cookie: OnBeginRequest=0; path=/
Set-Cookie: OnAuthenticateRequest=1; path=/
Set-Cookie: OnPostAuthenticateRequest=2; path=/
Set-Cookie: OnBeginRequest=0; path=/
Set-Cookie: OnAuthenticateRequest=1; path=/
Set-Cookie: OnPostAuthenticateRequest=2; …Run Code Online (Sandbox Code Playgroud) 代码bellow与Typescript 2.1.6一起正常工作
function create<T>(prototype: T, pojo: Object): T {
// ...
return Object.create(prototype, descriptors) as T;
}
Run Code Online (Sandbox Code Playgroud)
更新到Typescript 2.2.1后,我收到以下错误:
错误TS2345:类型'T'的参数不能分配给'object'类型的参数.
在 Elasticsearch.NET 6.x 中,可以使用以下IElasticClient方法创建索引:
var response = elasticClient.Create(
"my-index-name",
index => index .Mappings(
ms => ms.Map<MyDocumentType>(
x => x.AutoMap()
)
)
);
Run Code Online (Sandbox Code Playgroud)
在 Elasticsearch.NET 版本 7 中删除了方法。
在 ASP.NET Core 2.0 中,我使用类上的ConfigureServices方法Startup来连接 Autofac,包装现有的services注册并添加额外的一次。
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// Standard service registrations (ex: services.AddMvc())
// ...
// Autofac
var builder = new ContainerBuilder();
builder.Populate(services); // wrap service registrations
builder.RegisterModule<MyModule>(); // add extra registrations
this.ApplicationContainer = builder.Build();
return new AutofacServiceProvider(this.ApplicationContainer);
}
Run Code Online (Sandbox Code Playgroud)
由于ConfigureService方法void在 ASP.NET Core 3.0 中并且不再支持返回参数IServiceProvider,我该如何连接 Autofac?
在 .NET Core 3 中,我扩展了ComplexTypeModelBinder类来为特定类创建自定义模型绑定器。
主要目标是通过方法覆盖模型实例的创建CreateModel。
public MyModelBinder: ComplexTypeModelBinder
{
// Constructor here...
protected override object CreateModel(ModelBindingContext bindingContext)
{
// Create model instance based on custom condition.
}
}
Run Code Online (Sandbox Code Playgroud)
升级到 .NET 5 后,我收到一条编译警告,需要替换ComplexTypeModelBinder为ComplexObjectModelBinder:
警告 CS0618:“ComplexTypeModelBinder”已过时:“此类型已过时,将在未来版本中删除。请改用 ComplexObjectModelBinder。'
问题是ComplexObjectModelBinder密封类和CreateModel方法是internal密封的,因此子类方法不再起作用。
c# ×4
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
autofac ×1
cookies ×1
dictionary ×1
generics ×1
iis ×1
linq ×1
nest ×1
razor ×1
todictionary ×1
typescript ×1
where ×1