.net-core

Why .NET Standard 2 build references many assemblies instead of single netstandard.dll assembly

大城市里の小女人 提交于 2021-02-17 05:15:13
问题 Unlike .NET Standard 1, .NET Standard 2 introduces a single netstandard.dll reference assembly. However, when compiling (with .NET Core SDK 2.2.203) with dotnet build we can see that it adds references to many assemblies (113), all under netstandard.library/2.0.3/build/netstandard2.0/ref/*.dll . One of these references is netstandard.dll . $ grep TargetFramework *.csproj <TargetFramework>netstandard2.0</TargetFramework> $ dotnet build --verbosity normal | grep -o netstandard.library/2.0.3

If .Net Core can run on Windows, why can't you reference a .Net Core DLL in .Net Framework?

吃可爱长大的小学妹 提交于 2021-02-17 04:49:28
问题 I get why .Net Framework could cause issues in .Net Core, IE because an API specific to the Windows platform doesn't exist. But why wouldn't you be able to directly reference .Net Core as a library in .Net Framework? If .Net Core runs on windows, what is preventing a .Net Framework app from using .Net Core as if it were a library? I'm aware that you can port the .Net Core library to a .Net Standard Library, but my question is why .Net Framework can't just reference anything written in .Net

If .Net Core can run on Windows, why can't you reference a .Net Core DLL in .Net Framework?

可紊 提交于 2021-02-17 04:48:05
问题 I get why .Net Framework could cause issues in .Net Core, IE because an API specific to the Windows platform doesn't exist. But why wouldn't you be able to directly reference .Net Core as a library in .Net Framework? If .Net Core runs on windows, what is preventing a .Net Framework app from using .Net Core as if it were a library? I'm aware that you can port the .Net Core library to a .Net Standard Library, but my question is why .Net Framework can't just reference anything written in .Net

Query or deserialize json with dynamic keys using System.Text.Json

╄→гoц情女王★ 提交于 2021-02-17 02:48:30
问题 I have json that looks like this, the key "123" could be any number. { "key1": "", "key2": { "items": { "123": { "pageid": 123, "name": "data" } } } } I want to deserialize or query the json with System.Text.Json so i can get the value of the key "name". How can I do that with System.Text.Json? I'm using .NET Core 3.1. 回答1: Something like: public class Rootobject { public string key1 { get; set; } public InnerObject key2 { get; set; } } public class InnerObject { public Dictionary<string,

EF Core Many-to-Many self join

吃可爱长大的小学妹 提交于 2021-02-16 21:04:57
问题 I am trying to describe a many-to-many self-referential relationship to Entity Framework Core 2. Essentially what I'm trying to model is a sort of tree structure, in which each element can have an arbitrary number of parent and child elements (so I guess more a graph than a tree). Here's what I have so far: public class OrgLevel { ... public ICollection<OrgLevelOrgLevels> OrgLevelOrgLevelsAsParent { get; set; } public ICollection<OrgLevelOrgLevels> OrgLevelOrgLevelsAsChild { get; set; }

EF Core Many-to-Many self join

北慕城南 提交于 2021-02-16 21:03:38
问题 I am trying to describe a many-to-many self-referential relationship to Entity Framework Core 2. Essentially what I'm trying to model is a sort of tree structure, in which each element can have an arbitrary number of parent and child elements (so I guess more a graph than a tree). Here's what I have so far: public class OrgLevel { ... public ICollection<OrgLevelOrgLevels> OrgLevelOrgLevelsAsParent { get; set; } public ICollection<OrgLevelOrgLevels> OrgLevelOrgLevelsAsChild { get; set; }

.Net Core 3 Worker Integration Tests

你说的曾经没有我的故事 提交于 2021-02-16 20:14:11
问题 For integration testing Asp.Net Core application we have WebApplicationFactory. But how to test Worker ( HostedService ) that is not web application? I don't want to copy the whole DI configuration in SUT like in this question. Is it possible to use original configuration and override some of dependencies like we do for web application in WebApplicationFactory.WithWebHostBuilder? 回答1: I wasn't able to find any solution for Worker services integration testing hence I made adoption of

Why does System.Text Json Serialiser not serialise this generic property but Json.NET does?

天大地大妈咪最大 提交于 2021-02-16 18:17:05
问题 I have the following situation. I have simplified the problem into the following example, although my real situation is more complicated. System.Text.Json does not serialise the object fully but Newtonsoft Json.NET does. Suppose I have the following class structure. public class A { public string AProperty { get; set; } = "A"; } public class A<T> : A where T : class, new() { public T TObject { get; set; } = new T(); } public class B { public string BProperty { get; set; } = "B"; } public

Unit test serilog configuration

烈酒焚心 提交于 2021-02-16 18:07:57
问题 I have a piece of code for setting up serilog based on some custom configuration combined with hosting environment. E.g. the application writes to one sink in development and another sink in production. I'm trying to figure out how to write tests for this piece of code. Basically, I want to write a test that checks that a sink only is added if the environment name is set to a given value, and that the sink configuration, like log file path, respects the custom configuration that I provide.

Unit test serilog configuration

半腔热情 提交于 2021-02-16 18:06:51
问题 I have a piece of code for setting up serilog based on some custom configuration combined with hosting environment. E.g. the application writes to one sink in development and another sink in production. I'm trying to figure out how to write tests for this piece of code. Basically, I want to write a test that checks that a sink only is added if the environment name is set to a given value, and that the sink configuration, like log file path, respects the custom configuration that I provide.