[{"data":1,"prerenderedAt":475},["ShallowReactive",2],{"article-visual-studio-how-to-target-differentlatest-c-version-net-core-3-and-c-8":3},{"article":4,"tags":265,"previous":280,"next":381},{"id":5,"title":6,"author":7,"body":8,"createdAt":255,"description":7,"extension":256,"img":43,"meta":257,"navigation":258,"path":259,"seo":260,"stem":261,"tags":262,"updatedAt":255,"__hash__":264},"articles\u002Farticles\u002Fvisual-studio-how-to-target-differentlatest-c-version-net-core-3-and-c-8.md","Visual Studio How to target different\u002Flatest c# version (.NET Core 3 and C# 8)",null,{"type":9,"value":10,"toc":251},"minimark",[11,15,31,52,63,70,152,155,166,186,192,199,205,208,229,232,237,240,247],[12,13,14],"p",{},"Know which version of c# you were actually using or wanting to try latest c# 8 features?  How to check?",[16,17,18,22,25,28],"ul",{},[19,20,21],"li",{},"Open the project properties window (right click on project, select properties)",[19,23,24],{},"Select ‘Build’ from the left hand side options",[19,26,27],{},"Scroll down to the Advanced options",[19,29,30],{},"Select the desired version of c#, click ok   Wanting c# 8 selection? (released with .NET Core 3, and available as part of Visual Studio 2019 (latest release)     * For me, open Visual Studio select Help – Check for Updates (and download the latest release of VS.NET)",[12,32,33,46,47],{},[34,35,37],"a",{"href":36},"\u002Farticles\u002Fimages\u002Fimage_637062268790299787.png",[38,39],"img",{"title":40,"style":41,"border":42,"alt":40,"src":43,"width":44,"height":45},"image","border: 0px currentcolor; border-image: none; display: inline; background-image: none;",0,"\u002Farticles\u002Fimages\u002Fimage_thumb_637062268791269872.png",393,100,"   After the update, open VS.NET revisit project properties and c# 8 should be available in the ‘Language Version’ selection list….but wait it is not there (the selection list is disabled and they gave me a clue…",[34,48,51],{"href":49,"target":50},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcsharp\u002Flanguage-reference\u002Fconfigure-language-version","_blank","Why can’t I select a different c# version?",[12,53,54],{},[34,55,57],{"href":56},"\u002Farticles\u002Fimages\u002Fimage_637062268792583127.png",[38,58],{"title":40,"style":59,"border":42,"alt":40,"src":60,"width":61,"height":62},"margin: 0px; border: 0px currentcolor; border-image: none; display: inline; background-image: none;","\u002Farticles\u002Fimages\u002Fimage_thumb_637062268793729110.png",489,269,[12,64,65,69],{},[66,67,68],"em",{},"”The latest C# compiler determines a default language version based on your project's target framework or frameworks. This is because the C# language may have features that rely on types or runtime components that are not available in every .NET implementation. This also ensures that for whatever target your project is built against, you get the highest compatible language version by default.”","  Ok, so now the c# version is not selectable, it is based on the projects target framework. Here is the conversion chart…    ",[71,72,73,89],"table",{},[74,75,76],"thead",{},[77,78,79,83,86],"tr",{},[80,81,82],"th",{},"Target framework",[80,84,85],{},"version",[80,87,88],{},"C# language version default",[90,91,92,104,114,124,133,142],"tbody",{},[77,93,94,98,101],{},[95,96,97],"td",{},".NET Core",[95,99,100],{},"3.x",[95,102,103],{},"C# 8.0",[77,105,106,108,111],{},[95,107,97],{},[95,109,110],{},"2.x",[95,112,113],{},"C# 7.3",[77,115,116,119,122],{},[95,117,118],{},".NET Standard",[95,120,121],{},"2.1",[95,123,103],{},[77,125,126,128,131],{},[95,127,118],{},[95,129,130],{},"2.0",[95,132,113],{},[77,134,135,137,140],{},[95,136,118],{},[95,138,139],{},"1.x",[95,141,113],{},[77,143,144,147,150],{},[95,145,146],{},".NET Framework",[95,148,149],{},"all",[95,151,113],{},[153,154],"br",{},[12,156,157,158],{},"Finally, that was my answer.  ",[34,159,161],{"href":160},"\u002Farticles\u002Fimages\u002Fimage_637062268794831916.png",[38,162],{"title":40,"style":41,"border":42,"alt":40,"src":163,"width":164,"height":165},"\u002Farticles\u002Fimages\u002Fimage_thumb_637062268796116567.png",499,293,[12,167,168,169,173,174,178,179,183,185],{},"References    ",[34,170,172],{"href":171,"target":50},"https:\u002F\u002Fdotnet.microsoft.com\u002Fdownload\u002Fdotnet-core\u002F3.0","Download .NET Core 3 Direct"," option Released 2019-09-23    ",[34,175,177],{"href":176,"target":50},"https:\u002F\u002Fwww.dotnetcurry.com\u002Fcsharp\u002F1489\u002Fcsharp-8-visual-studio-2019","New C# 8 Features","    ",[180,181,182],"strong",{},"One of the more important features…",[153,184],{},"\nNullable reference types (this is good addition)",[12,187,188,189,191],{},"The core idea is to allow variable type definitions to specify whether they can have null value assigned to them or not:     Weapon? canBeNull;",[153,190],{},"\nIWeapon cantBeNull;",[12,193,194,195,198],{},"Assigning a null value or a potential null value to a non-nullable variable results in a compiler warning\n(",[180,196,197],{},"the developer can configure the build to fail in case of such warnings, to be extra safe","):",[12,200,201,202,204],{},"canBeNull = null\n\u002F\u002F no warning",[153,203],{},"\ncantBeNull = null\n\u002F\u002F warning",[12,206,207],{},"cantBeNull = canBeNull;\n\u002F\u002F warning",[12,209,210,211,213,214,216,217,219,220,222,223,225,226,228],{},"Similarly, warnings are generated when dereferencing a nullable variable without checking it for null value first:",[153,212],{},"\ncanBeNull.Repair();\n\u002F\u002F warning",[153,215],{},"\ncantBeNull.Repair();\n\u002F\u002F no warning",[153,218],{},"\nif (canBeNull != null)",[153,221],{},"\n{",[153,224],{},"\ncanBeNull.Repair();\n\u002F\u002F no warning",[153,227],{},"\n}",[12,230,231],{},"The problem with such a change is that it breaks existing code:\nthe feature assumes that all variables from before the change are non-nullable.\nTo cope with that, static analysis for null-safety can be enabled selectively with a compiler switch at the project level.",[12,233,234],{},[180,235,236],{},"Developers can opt-in for nullability checking when they are ready to deal with the resulting warnings.",[12,238,239],{},"Still, this should be in their own best interest, as the warnings might reveal potential bugs in their code.",[12,241,242,243,246],{},"The switch is persisted as a property in the project file. There’s no user interface in Visual Studio 2019 yet for changing its value.\nTherefore, the following line must be ",[180,244,245],{},"added manually to the first PropertyGroup element of the project file to enable\nthe feature for the project",":",[248,249,250],"nullable-context-options",{},"\nenable\n",{"title":252,"searchDepth":253,"depth":253,"links":254},"",2,[],"2019-10-09T14:07:59.731Z","md",{},true,"\u002Farticles\u002Fvisual-studio-how-to-target-differentlatest-c-version-net-core-3-and-c-8",{"title":6,"description":7},"articles\u002Fvisual-studio-how-to-target-differentlatest-c-version-net-core-3-and-c-8",[263],"visualstudio","ypmVFhZTDDNRkorn4dMwIhgjCKVDrMBz-yfEqjhwNtM",[266],{"id":267,"title":268,"body":269,"description":273,"extension":256,"img":274,"meta":275,"name":263,"navigation":258,"path":276,"seo":277,"stem":278,"__hash__":279},"tags\u002Ftags\u002Fvisualstudio.md","Visualstudio",{"type":9,"value":270,"toc":271},[],{"title":252,"searchDepth":253,"depth":253,"links":272},[],"Develop apps for Android, iOS, Mac, Windows, web, and cloud","https:\u002F\u002Fimages.unsplash.com\u002Fphoto-1598313183973-4effcded8d5e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=675&q=80",{},"\u002Ftags\u002Fvisualstudio",{"description":273},"tags\u002Fvisualstudio","glm3bYyBlAXGun4NJe-CV_iOzhszydeBRIpbGNNLeEk",{"id":281,"title":282,"author":283,"body":284,"createdAt":372,"description":373,"extension":256,"img":7,"meta":374,"navigation":258,"path":375,"seo":376,"stem":377,"tags":378,"updatedAt":372,"__hash__":380},"articles\u002Farticles\u002Fhttpclient-saga--related-noteslinks.md","HttpClient Saga and Related Notes Links","[object Object]",{"type":9,"value":285,"toc":370},[286,301,317,320,332,335,350,353,356,363],[12,287,288,289,292,293,297,298],{},"On ",[180,290,291],{},".Net Full framework",", you can control the number of outgoing client connections by setting ",[34,294,296],{"href":295},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fdotnet\u002Fapi\u002Fsystem.net.servicepointmanager.defaultconnectionlimit?view=netframework-4.7#System_Net_ServicePointManager_DefaultConnectionLimit","ServicePointManager.DefaultConnectionLimit"," to the desired number. ",[180,299,300],{},"It is 2 by default.",[12,302,288,303,306,307,311,312,316],{},[180,304,305],{},".Net Core",", you can set it by changing ",[34,308,310],{"href":309},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fdotnet\u002Fapi\u002Fsystem.net.http.httpclienthandler.maxconnectionsperserver?view=netcore-2.0#System_Net_Http_HttpClientHandler_MaxConnectionsPerServer","HttpClientHandler.MaxConnectionsPerServer"," to your desired limit. The default is int.MaxValue -- much higher than the default for the full framework.  Gets or sets the maximum number of concurrent connections (per server endpoint) allowed when making requests using an ",[34,313,315],{"href":314},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fdotnet\u002Fapi\u002Fsystem.net.http.httpclient?view=netcore-2.0","HttpClient"," object. Note that the limit is per server endpoint, so for example a value of 256 would permit 256 concurrent connections to http:\u002F\u002Fwww.adatum.com\u002F and another 256 to http:\u002F\u002Fwww.adventure-works.com\u002F",[12,318,319],{},"References:",[12,321,322,327,328,330],{},[34,323,326],{"href":295,"target":50,"rel":324},[325],"noopener","ServicePointManager"," ",[153,329],{},[34,331,310],{"href":309},[12,333,334],{},"Before the introduction of the HttpClientFactory in .NET Core 2.1, it was common to use the HttpClient to make HTTP requests to services.  One of the big problems with using the HttpClient was the misuse of it. HttpClient implements IDisposable, when anything implements IDisposable, best practice tells us that we should wrap the calls we are making inside a using statement to allow proper disposal of the object. However the HTTPClient is different, even though it implements IDisposable, we shouldn’t be wrapping this in a using statement. The HttpClient is reusable and thread safe, so it makes it very inefficient and unnecessary to dispose of the HttpClient after each request is made. When you dispose of the HttpClient object the underlying socket is not immediately released. This can cause some serious issues like ‘sockets exhaustion’. The recommended way is to instantiated it once and reused it throughout the life of an application.",[12,336,337,327,342,327,344,346,347,349],{},[34,338,341],{"href":339,"target":50,"rel":340},"https:\u002F\u002Faspnetmonsters.com\u002F2016\u002F08\u002F2016-08-27-httpclientwrong\u002F",[325],"YOU'RE USING HTTPCLIENT WRONG AND IT IS DESTABILIZING YOUR SOFTWARE",[153,343],{},[153,345],{},"Unfortunately, not disposing of our HttpClient instance does not fix all of the issues with the HttpClient. The issue with creating a single instance of the HttpClient is that it won’t respect DNS changes, because we are creating a single instance of the HttpClient, we are keeping the connection open, ready to be reused. ",[153,348],{},"Due to these issues, the HttpClientFactory was created.",[12,351,352],{},"Using the HttpClientFactory removes the issues that we can run into when using the HttpClient, such as ‘sockets exhaustion’, due to not re-using the HttpClient throughout the life of an application.",[12,354,355],{},"When reusing your HttpClient you could then run into the issue of the client not respecting DNS changes. While the HttpClientFactory by default has a handler lifetime set to 2 mins, to get around DNS change issue, we are also able to set this handler lifetime to whatever we want.",[12,357,358],{},[34,359,362],{"href":360,"target":50,"rel":361},"http:\u002F\u002Fanthonygiretti.com\u002F2018\u002F09\u002F06\u002Fhow-to-unit-test-a-class-that-consumes-an-httpclient-with-ihttpclientfactory-in-asp-net-core\u002F",[325],"How to unit test a class that consumes an HttpClient with IHttpClientFactory in ASP.NET Core?",[12,364,365],{},[34,366,369],{"href":367,"target":50,"rel":368},"https:\u002F\u002Fcodereview.stackexchange.com\u002Fquestions\u002F227596\u002Fsimple-httpclient-usage-for-integration-tests-in-net-core",[325],"Integration Testing",{"title":252,"searchDepth":253,"depth":253,"links":371},[],"2019-10-09T20:15:06.625Z","Recently, we migrated our applications to latest windows server from 2008 and ran into a number of issues with sockets, connection limits and timeouts.  The root of our issues is the default connection limits that we had not encountered before.  Below is part of our investigation and subsequent resolution to these issues.",{},"\u002Farticles\u002Fhttpclient-saga-related-noteslinks",{"title":282,"description":373},"articles\u002Fhttpclient-saga--related-noteslinks",[379],"netcore","l1pMNA9gO17s0hmcoHaNRdtKD9yGrQyXApQIDK9aZKI",{"id":382,"title":383,"author":7,"body":384,"createdAt":466,"description":467,"extension":256,"img":416,"meta":468,"navigation":258,"path":469,"seo":470,"stem":471,"tags":472,"updatedAt":466,"__hash__":474},"articles\u002Farticles\u002Fproduct-review-ndepend-part-1.md","Product Review NDepend Part 1",{"type":9,"value":385,"toc":464},[386,394,402,408,419,422,432,435,445,448,458],[12,387,388,389],{},"Today, I tried a code review extension for Visual Studio.  The product ",[34,390,393],{"href":391,"target":50,"rel":392},"https:\u002F\u002Fwww.ndepend.com\u002F",[325],"NDepend",[16,395,396,399],{},[19,397,398],{},"As it was as an extension, the installation process was simple and quick and painless",[19,400,401],{},"Setting up the product to review\u002Fanalyze my solution (including many projects) was also very easy!",[12,403,404,405,407],{},"Very quickly (within minutes) the extension was able to analyze my code against many best practices, standards and coding techniques.  There are so many features within this product it is hard to adequately evaluate all features in one go.  I will document initial findings and feelings about this product, and hope to provide future reviews as I discover each of the features.",[153,406],{},"\nThe immediate first thing I see is overview\u002Fdashboard of current solution\u002Fstatus, including 75 427 lines of code with a 5.5% debt ratio.",[12,409,410],{},[34,411,413],{"href":412},"\u002Farticles\u002Fimages\u002Fimage_636986200288720521.png",[38,414],{"style":415,"title":40,"src":416,"alt":40,"width":417,"height":418,"border":42},"border: 0px currentcolor; display: inline; background-image: none;","\u002Farticles\u002Fimages\u002Fimage_thumb_636986200289974139.png",454,303,[12,420,421],{},"Of particular interest to me was the debt and issues identified.  The system includes 100+ code rules that can detect a wide range of code smells including complex methods, dead-code, bad object orientated usage etc..",[12,423,424],{},[34,425,427],{"href":426},"\u002Farticles\u002Fimages\u002Fimage_636986200291159252.png",[38,428],{"style":415,"title":40,"src":429,"alt":40,"width":430,"height":431,"border":42},"\u002Farticles\u002Fimages\u002Fimage_thumb_636986200292423409.png",457,202,[12,433,434],{},"Changing the sorting of issue, shows code related to each (in this case 70 rules)",[12,436,437],{},[34,438,440],{"href":439},"\u002Farticles\u002Fimages\u002Fimage_636986200294068991.png",[38,441],{"style":415,"title":40,"src":442,"alt":40,"width":443,"height":444,"border":42},"\u002Farticles\u002Fimages\u002Fimage_thumb_636986200295573812.png",208,470,[12,446,447],{},"Drilling into a few rules (by double clicking on any) you can see how this can be a very good tool to very quickly identify and put plans in place to resolve\u002Fcleanup and generally improve the code quality.  Rules can be edited, categorized and prioritized to meet your group\u002Fcompany standards.  Clicking on particular rules\u002Fwarnings allows you to drill directly to the code\u002Fproblem identified.  There is no hunting-pecking and trying to figure out what it thinks is incorrect.",[12,449,450],{},[34,451,453],{"href":452},"\u002Farticles\u002Fimages\u002Fimage_636986200296582570.png",[38,454],{"style":415,"title":40,"src":455,"alt":40,"width":456,"height":457,"border":42},"\u002Farticles\u002Fimages\u002Fimage_thumb_636986200298017103.png",453,236,[12,459,460,461,463],{},"Honestly, it is addictive to review the issues found and try to wipe them out.  Using this tool alongside Reharper R#\u002FCodeRush it is quite easy to generally clean up the solution.  Fixing issues, re-running the analysis just to find fewer identified issues is very satisfying.",[153,462],{},"\nI have not mentioned anything about the product’s ability to evaluate\u002Fwatch trends around code changes.  I hope to use this capability in the near future.  To be continued.",{"title":252,"searchDepth":253,"depth":253,"links":465},[],"2019-07-13T13:07:09.892Z","NDepend static code analysis tool that empowers .NET architects and developers to make informed decisions.  The tool estimates the Technical Debt evolution since the baseline.",{},"\u002Farticles\u002Fproduct-review-ndepend-part-1",{"title":383,"description":467},"articles\u002Fproduct-review-ndepend-part-1",[473],"productreview","BJhDIovWrZxHjaHDGCQMsFdAZ4ogTimaF_mfyhNkV9I",1781574769333]