Category: .NET
-
Correct abstraction–.NET Core IFileProvider
Create the right abstraction and they will implement it. I was delighted by finding that the .NET Core has an IFileProvider : https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.fileproviders.ifileprovider?view=aspnetcore-2.2 . An obvious implementation is PhysicalFileProvider : https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.fileproviders.physicalfileprovider?view=aspnetcore-2.2 A not so obvious implementation,but normal from a programmers mind,is NullFileProvider: https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.fileproviders.nullfileprovider?view=aspnetcore-2.2 And,because we have already 2 providers,makes sense a CompositeFileProvider: https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.fileproviders.compositefileprovider?view=aspnetcore-2.2 And because…
-
Simple serialize of encoding
My problem was the serialize of the Encoding . Let’s suppose that we have a class that have a property Encoding( maybe to read a file ). We want to serialize this class in order to let the administrator/people to decide what will be the encoding. When we serialize( obvious,with NewtonSoftJson),we obtain this kind of…
-
C# integration testing in AzureDevOps with Docker containers– SqlServer and Cachet example
Every software that we make depends on others. For Stankins,as a general ETL data,it is more important to be tested with real data providers.For example,we may want to take data from Sql Server and send to Cachet . How can we have a SqlServer and a Cachet up and running easy ? The obvious answer…
-
Create a new exception–add fields and/or properties
This post is not about why we need custom exception (https://blogs.msdn.microsoft.com/jaredpar/2008/10/20/custom-exceptions-when-should-you-create-them/ ) . It is (more a rant ) about a specific item in best practices in Exceptions( https://docs.microsoft.com/en-us/dotnet/standard/exceptions/best-practices-for-exceptions ) It says: In custom exceptions,provide additional properties as needed Provide additional properties for an exception (in addition to the custom message string) only when there’s…
-
OpenSource library- publishing
Following the rules at https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/publish-nuget-package Nr Recomandation AOP Roslyn 1 DO publish stable packages and pre-release packages you want community feedback on to NuGet.org. Done 2 CONSIDER publishing pre-release packages to a MyGet feed from a continuous integration build. No 3 CONSIDER testing packages in your development environment using a local feed or MyGet. Check…
-
OpenSource library–Strong naming
The strong naming is something that I have not have done usually,so it will be interesting following https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/strong-naming . Nr Recomandation AOP Roslyn 1 CONSIDER strong naming your library’s assemblies. Not –see below 2 CONSIDER adding the strong naming key to your source control system. easy- not 3 CONSIDER incrementing the assembly version on only…
-
My Async Await tutorials
Rule of thumb: just await / async from top to down. To deeply understand async await in .NET Core,please follow the following resources: 1. https://channel9.msdn.com/Events/TechDays/Techdays-2014-the-Netherlands/Async-programming-deep-dive – to gain inner knowledge about what code is async / await 2. Read https://blog.stephencleary.com/2012/02/async-and-await.html to have started into async await 3. Read MSDN for a better understanding…
-
Connections strings to config
I have the opportunity to work on some pretty old code . There were many projects,all that had a sort of connection string to the database. This kind of code were in like > 11 places : string connectionstring = “Data Source=.\\SqlServer;Initial Catalog=myDB;Integrated Security=SSPI;”; The task was to modify this in something that could read…
-
Circular references on .NET,Entity Framework and WebAPI
Imagine having a class Department( ID,Name) and Employee ( ID,Name,IDDepartment) . You want to return in the WebAPI the Departments with the Employee . It is simple to wrote this code: But the problem is with circular references when serializing : The Department has a list of Employees that have a Department that have a…
-
Interpreter–part 7 of n–thank you
In our days you cannot build a project without help from other projects. So it is your project – it is build on the shoulder of others( https://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants ) Add a third party notice and thanks others that contributes with components to your project. I have discovered https://github.com/KrystianKolad/DotnetThx – and running it gives me that…