.net-standard

How to properly unit test a .NET project with multiple target frameworks, given implementation differences among targets?

时光毁灭记忆、已成空白 提交于 2019-11-30 01:40:22
Consider a .NET class library that targets the following frameworks: .NET Framework 2.0 .NET Framework 4.6 .NET Standard 1.0 .NET Standard 1.3 .NET Portable Profile336 Let's not immediately worry about why this is the exact list of target frameworks. Supposing that the external API across all target frameworks is identical, but each individual target framework has some code that's unique to that framework, how do I properly write the unit tests that cover the code from all target frameworks? I'm running Visual Studio 2017 Community. I've cooked up a ready-to-go minimal sample on GitHub here

Unit testing internal methods in VS2017 .Net Standard library

北战南征 提交于 2019-11-29 22:43:43
I am currently playing around with the latest Visual Studio 2017 Release Candidate by creating a .Net Standard 1.6 library. I am using xUnit to unit test my code and was wondering if you can still testing internal methods in VS2017. I remember that you could all a line AssemblyInfo.cs class in VS2015 that would enable specified projects to see internal methods [assembly:InternalsVisibleTo("MyTests")] As there is no AssemblyInfo.cs class in VS2017 .Net Standard projects I was wondering if you can still unit test internal methods? According to .NET docs for the InternalsVisibleToAttribute : The

Failed to load Xamarin Forms project with .NET Standard 2.0 Lib in Rider

时光毁灭记忆、已成空白 提交于 2019-11-29 18:55:50
问题 TL;DR; Are Xamarin Forms projects with .NET Standard library 2.0 supported in Rider? I created a small Xamarin project in Visual Studio 2017.3 (Windows) using the blank forms app multiplatform wizard. Microsoft dropped the the option to create a PCL recently in the Windows version of VS and provides .NET Standard only. Thus I selected that one. Now I wanted to try out development on Mac directly using Rider so that I don't have to run a Windows VM (I really like Resharper so I am bound to

Can I add .NET Standard libraries to PCL

穿精又带淫゛_ 提交于 2019-11-29 18:39:28
I have a Xamarin Forms app and using Visual Studio 2015. 1) Can I add to PCL .NET Standard libraries? Are there any issues with that? 2) Editing resx of a .NET Standard library crashes VS2015. Any workaround? You can add .Net standard libraries to PCLs, but only lower versions. It depends on your profile version, so you almost have to try it and see if it works. You can add PCLs to .Net standard libraries, by setting a fallback to the PCL in your csproj file. You can read about it here: https://oren.codes/2017/04/23/using-xamarin-forms-with-net-standard-vs-2017-edition/ 来源: https:/

Running .NET Standard binaries on different frameworks

∥☆過路亽.° 提交于 2019-11-29 15:11:46
I understand targeting .NET Standard 2 means that the frameworks between .net core, mono and the full .net framework, but I'd like to understand what that means for the binaries created by the different frameworks. So if I create a console program targeting .NET Standard 2 and compile using .NET Framework, can only the full .NET Framework run this file? If they can all run the files, how would I run the .NET Core .dll executable console using the full framework or Mono? So basically are the binaries created by each framework (targeting .NET Standard) able to run using the other frameworks? I

.NET Standard - Merge a certificate and a private key into a .pfx file programmatically

拟墨画扇 提交于 2019-11-29 14:08:11
Is there any way to combine a certificate and a key (both received separately as Base64 strings from a service) into a .pfx file using C#/.NET Standard programmatically ? Using a tool is not an option, since I need to automate it. The context: I need to load a certificate and a private key (separate Base64 strings without headers and footers) to a X509Certificate2 object to pass it on to the app from a .NET Standard 1.6 library. The problem is, there is no PrivateKey property in the X509Certificate2 class in .NET Standard! So the only way for me to actually load the private key in a

Microsoft.ServiceBus.Messaging vs Microsoft.Azure.ServiceBus

柔情痞子 提交于 2019-11-29 12:16:59
问题 MS has recently introduced the Microsoft.Azure.ServiceBus namespace. https://github.com/Azure/azure-service-bus/blob/master/samples/readme.md It is geared for the new .net standard framework (as if MS doesn't have enough semi-redundant code bases) My question is, how much better could it be in terms of performance? I can say with confidence, that the Microsoft.ServiceBus.Messaging leaves lots to be desired, in particular when it comes to persistent receiving. A very useful feature of the

How to authenticate without prompt to CRM Dynamics Online webservices with ADAL, NetStandard, and Azure AD

梦想的初衷 提交于 2019-11-29 12:05:18
I'm currently trying to create a Xamarin App in order to get some info from a Dynamics 365 online instance. The code that authenticate with AD and access the CRM api is deported in a NetStandard (v1.6) Library. I use the following NuGets : Microsoft.IdentityModel.Clients.ActiveDirectory (3.13.9) NETStandard.Library (1.6.1) I followed the following tutorial in order to link AD with my Dynamics instance : https://nishantrana.me/2016/11/13/register-a-dynamics-365-app-with-azure-active-directory/ Here is my ActiveDirectory helper : public static class ADHelper { public async static Task

Disable transitive project reference in .NET Standard 2

非 Y 不嫁゛ 提交于 2019-11-29 07:38:00
I'm writing an MVC website using ASP.NET Core 2.0. In the ASP.NET Core project (let's call it Web ), I reference a .NET Standard 2 project in the same solution (let's call it Service ). The Service project also references a third .NET Standard 2 library in the solution (let's call this one Business ). The Business project declares a type called Model . The problem is that I can use Model in the Web project (i.e. the compiler sees the type Model and I can do var a = new Model(); ) as if the Web project has referenced Business , but it actually only has a reference to Service . How can I hide

New .csproj format - How to specify entire directory as “linked file” to a subdirectory?

时光毁灭记忆、已成空白 提交于 2019-11-29 06:19:12
With the new .csproj format (as well as the old), it is possible to add files as linked outside of the project folder: <EmbeddedResource Include="..\..\..\Demo\Sample.cs" Link="Resources\Sample.cs" /> It is also possible to use a glob pattern to include multiple files: <EmbeddedResource Include="..\..\..\Demo\*.cs" /> But how do you combine the two? What I Tried <EmbeddedResource Include="..\..\..\Demo\*.cs" Link="Resources\*.cs" /> <EmbeddedResource Include="..\..\..\Demo\*.cs" Link="Resources\*" /> <EmbeddedResource Include="..\..\..\Demo\*.cs" Link="Resources\" /> The first two only create