Adding Links to the NETStandard Class Library

I'm trying to figure out the NETStandard class libraries for the potential NuGet package I'm working on. This is the first time I play with the NuGet and NETStandard packages, so I lost some points a little, one of which refers to system libraries.

The type dynamicis part System.Runtime.CompilerServices.DynamicAttribute, but there is no link to the specified DLL. Although I would do it, but I cannot do it. I suppose this does not work as a framework class library?

If I right-click on my folder Dependenciesin my solution explorer and clicked Add Reference..., I cannot find ANY dependencies that I can use. Not under the tab, Assembliesanything under AssembliesFrameworkor Extensions.

I'm just trying to figure out how this works, and why can't I find any dependencies?

+4
source share
1 answer

Right-click the node Dependencies of your project> Nuget Package Management> Overview and type “dynamic” in the search box. Select System.Dynamic.Runtimeat the top of the list, now you can use dynamicin your source code.


If you are like me, you are interested in the reason why you can use the keyword dynamicwithout reference to the DLR libraries in the method code, but you cannot continue reading in property declarations.

# , NETStandard.Library System.Dynamic.Runtime. 1 3 # dynamic vs var .

Line 1: dynamic a = new {a = 1, b = 2};
Line 2: a = new Class1();
Line 3: var b = new { a = 1, b = 2 };

.

Line 1: newobj     instance void class '<>f__AnonymousType0`2'<int32,int32>::.ctor(!0,!1)
Line 2: newobj     instance void ClassLibrary2.Class1::.ctor()
Line 3: newobj     instance void class '<>f__AnonymousType0`2'<int32,int32>::.ctor(!0,!1)

1 3 IL, . , . DLR.

, , auto dynamic.

public class Class1 { public dynamic Test { get; set; } }

IL auto-property dynamic, object, , getter setter, System.Runtime.CompilerServices.DynamicAttribute System.Dynamic.Runtime, DLR.

+4

Source: https://habr.com/ru/post/1676182/


All Articles