我正在尝试使用.NET 4.7开始一个新项目.我安装了Creators Update以及最新版本的Visual Studio 2017.当我启动项目和设备来选择.NET版本时,我所拥有的最新.NET框架版本是4.6.2.当我下载一个新的.NET框架时,它只列出4.6.2作为最新的MS,你可以下载.它说.NET 2017包含在VS 2017中.我缺少什么?
下面我将展示默认的 docker-compose.override.yml 文件,该文件是在向我的 ASP.NET 应用程序添加编排时为我创建的。这是使用 .NET Core 3.1。我右键单击项目文件 -> 添加 -> Container Orchestrator Support... 然后将 docker-compose 项目添加到我的解决方案中。(显然我在选项中选择了 Docker Compose)。
我想知道变量 APPDATA 在哪里被初始化,以便我可以理解完整路径。我了解卷是如何工作的;我只是想知道APPDATA的初始化方式和位置。
version: '3.4'
services:
myproject:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+:443;http://+:80
ports:
- "80"
- "443"
volumes:
- ${APPDATA}/Microsoft/UserSecrets:C:\Users\ContainerUser\AppData\Roaming\Microsoft\UserSecrets:ro
- ${APPDATA}/ASP.NET/Https:C:\Users\ContainerUser\AppData\Roaming\ASP.NET\Https:ro
Run Code Online (Sandbox Code Playgroud) 目标:返回时,通用枚举类型为相同类型.
注意:这在输入类型时有效,但我不明白为什么无法推断它们.
List<T> 然后回来 List<T>
IOrderedEnumerable<T> 然后回来 IOrderedEnumerable<T>
等等
当前方法(仅在输入所有类型时有效)
public static TEnumerable WithEach<TEnumerable, T>(this TEnumerable items, Action<T> action)
where TEnumerable : IEnumerable<T>
{
foreach (var item in items) action.Invoke(item);
return items;
}
Run Code Online (Sandbox Code Playgroud)
仅示例
var list = new List<int>(); //TODO: Mock random values
list.WithEach(x => Console.WriteLine(x)) //Here WithEach ideally returns List<int> following orignal type List<int>
.OrderBy(x => x)
.WithEach(x => Console.WriteLine(x)); //Here WithEach ideally returns IOrderedEnumerable<int> following OrderBy
Run Code Online (Sandbox Code Playgroud)
让它工作
var list = new List<int>(); //TODO: Mock random values
list.WithEach<List<int>, …Run Code Online (Sandbox Code Playgroud) 目标:在我使用自定义属性时删除编译器警告“CS0649”(从未分配字段)。
我有一个自定义属性(下面的代码只是示例):
[AttributeUsage(AttributeTargets.Field)]
public class MyCustomAttribute : Attribute { }
Run Code Online (Sandbox Code Playgroud)
然后我在一个字段上使用该属性:
[MyCustom]
private readonly SomeType someType;
Run Code Online (Sandbox Code Playgroud)
我的申请会自动填写 someType一个值,因此我们无需担心初始化它。
我仍然会在 Visual Studio 下看到一条波浪线,someType并且警告消息“字段“someType”从未分配给,并且它的默认值始终为空。
是否有我可以添加的属性或其他方法来MyCustomAttribute删除此编译器警告?
注意:我不想修改该字段或键入该字段在更远的范围内。我只是想添加属性,然后警告消失。
我在这里缺少什么
Visual Studio告诉我使用内联模式匹配并为我重写代码但是当它发生时我得到错误:
严重级代码描述项目文件行抑制状态错误CS8121类型为TReturnState的表达式不能由LightState类型的模式处理.DataModels C:\ Users\Michael\Documents\windows\GCMS UWP\Models\Models\Elements\Lights\Light.cs 77 Active
这是原始代码:
public override void UpdateState<TReturnState>(TReturnState returnState)
{
var newState = returnState as LightState;
if (newState != null)
State = newState;
base.UpdateState(returnState);
}
Run Code Online (Sandbox Code Playgroud)
这是VS为我重做它时的样子.
public override void UpdateState<TReturnState>(TReturnState returnState)
{
if (returnState is LightState newState)
State = newState;
base.UpdateState(returnState);
}
Run Code Online (Sandbox Code Playgroud)
我更喜欢调整后的方式,但我收到错误.我错过了什么或这是一个错误吗?
我正在使用的包:
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.3.1",
"Newtonsoft.Json": "9.0.1",
"System.ValueTuple": "4.3.0"
},
Run Code Online (Sandbox Code Playgroud)