[{"data":1,"prerenderedAt":3971},["ShallowReactive",2],{"tag-netcore":3},{"tag":4,"articles":24},{"id":5,"title":6,"body":7,"description":14,"extension":15,"img":16,"meta":17,"name":18,"navigation":19,"path":20,"seo":21,"stem":22,"__hash__":23},"tags\u002Ftags\u002Fnetcore.md","Netcore",{"type":8,"value":9,"toc":10},"minimark",[],{"title":11,"searchDepth":12,"depth":12,"links":13},"",2,[],".NET Core is a new version of .NET Framework, which is a free, open-source, general-purpose development platform maintained by Microsoft. It is a cross-platform framework that runs on Windows, macOS, and Linux operating systems.","md","https:\u002F\u002Fimages.unsplash.com\u002Fphoto-1598313183973-4effcded8d5e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=675&q=80",{},"netcore",true,"\u002Ftags\u002Fnetcore",{"description":14},"tags\u002Fnetcore","D5BWCPpKVXJTUKU0TRuD3sWQ9rXtqETGkxzHAK__g5w",[25,294,352,489,554,695,1033,1185,1284,1382,1542,1815,2234,2439,2622,2688,2821,3531,3606],{"id":26,"title":27,"author":28,"body":29,"createdAt":283,"description":284,"extension":15,"img":285,"meta":286,"navigation":19,"path":287,"seo":288,"stem":289,"tags":290,"updatedAt":283,"__hash__":293},"articles\u002Farticles\u002Fopenidconnect-proxy-authentication-required.md","OpenIdConnect  - Proxy Authentication Required",null,{"type":8,"value":30,"toc":281},[31,35,237,242,245,277],[32,33,34],"p",{},"While setting up ASP.NET Core with OpenID Connect I am getting the following exception on the web server (hosting via IIS).",[36,37,41],"pre",{"className":38,"code":39,"language":40,"meta":11,"style":11},"language-html shiki shiki-themes github-light github-dark","System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https:\u002F\u002Fchild.mydomain.com\u002FIdp\u002F.well-known\u002Fopenid-configuration'. ---> \nSystem.IO.IOException: IDX20807: Unable to retrieve document from: 'https:\u002F\u002Fchild.mydomain.com\u002FIdp\u002F.well-known\u002Fopenid-configuration'. \nHttpResponseMessage: 'StatusCode: 407, ReasonPhrase: 'Proxy Authorization Required', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, \nHeaders: { Proxy-Authenticate: NTLM Date: Wed, 08 Apr 2020 14:13:30 GMT Pragma: no-cache Cache-Control: no-cache Via: 1.1 ws5001.ch2m.com:8080 Proxy-Connection: keep-alive Content-Type: text\u002Fhtml; charset=\"UTF-8\" Content-Length: 415 }', HttpResponseMessage.Content: \n\u003C!DOCTYPE HTML PUBLIC \"-\u002F\u002FIETF\u002F\u002FDTD HTML 2.0\u002F\u002FEN\"> \u003Chtml>\u003Chead> \u003Ctitle>\n    407 Proxy Authentication Required\u003C\u002Ftitle> \u003C\u002Fhead>\u003Cbody> \n    Proxy Authentication Required \n\nThis server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.\n\u003C\u002Fbody>\u003C\u002Fhtml>\nat Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel) at\nMicrosoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel) at\nMicrosoft.IdentityModel.Protocols.ConfigurationManager1.GetConfigurationAsync(CancellationToken cancel) --- \nEnd of inner exception stack trace --- at\nMicrosoft.IdentityModel.Protocols.ConfigurationManager1.GetConfigurationAsync(CancellationToken cancel) at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler\n.HandleChallengeAsyncInternal(AuthenticationProperties properties) at\nMicrosoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleChallengeAsync(AuthenticationProperties properties) at\nMicrosoft.AspNetCore.Authentication.AuthenticationHandler`1.ChallengeAsync(AuthenticationProperties properties) at Microsoft.AspNetCore.Authentication.AuthenticationService.ChallengeAsync(HttpContext context, String scheme, AuthenticationProperties properties) at\nMicrosoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at\nMicrosoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at\nMicrosoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.\u003CInvoke>g__Awaited|(ExceptionHandlerMiddleware middleware, HttpContext context,\n","html",[42,43,44,53,58,64,70,110,131,137,143,149,164,170,176,182,188,194,200,206,212,218,224],"code",{"__ignoreMap":11},[45,46,49],"span",{"class":47,"line":48},"line",1,[45,50,52],{"class":51},"sVt8B","System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https:\u002F\u002Fchild.mydomain.com\u002FIdp\u002F.well-known\u002Fopenid-configuration'. ---> \n",[45,54,55],{"class":47,"line":12},[45,56,57],{"class":51},"System.IO.IOException: IDX20807: Unable to retrieve document from: 'https:\u002F\u002Fchild.mydomain.com\u002FIdp\u002F.well-known\u002Fopenid-configuration'. \n",[45,59,61],{"class":47,"line":60},3,[45,62,63],{"class":51},"HttpResponseMessage: 'StatusCode: 407, ReasonPhrase: 'Proxy Authorization Required', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, \n",[45,65,67],{"class":47,"line":66},4,[45,68,69],{"class":51},"Headers: { Proxy-Authenticate: NTLM Date: Wed, 08 Apr 2020 14:13:30 GMT Pragma: no-cache Cache-Control: no-cache Via: 1.1 ws5001.ch2m.com:8080 Proxy-Connection: keep-alive Content-Type: text\u002Fhtml; charset=\"UTF-8\" Content-Length: 415 }', HttpResponseMessage.Content: \n",[45,71,73,76,80,84,87,91,94,96,99,102,104,107],{"class":47,"line":72},5,[45,74,75],{"class":51},"\u003C!",[45,77,79],{"class":78},"s9eBZ","DOCTYPE",[45,81,83],{"class":82},"sScJk"," HTML",[45,85,86],{"class":82}," PUBLIC",[45,88,90],{"class":89},"sZZnC"," \"-\u002F\u002FIETF\u002F\u002FDTD HTML 2.0\u002F\u002FEN\"",[45,92,93],{"class":51},"> \u003C",[45,95,40],{"class":78},[45,97,98],{"class":51},">\u003C",[45,100,101],{"class":78},"head",[45,103,93],{"class":51},[45,105,106],{"class":78},"title",[45,108,109],{"class":51},">\n",[45,111,113,116,118,121,123,125,128],{"class":47,"line":112},6,[45,114,115],{"class":51},"    407 Proxy Authentication Required\u003C\u002F",[45,117,106],{"class":78},[45,119,120],{"class":51},"> \u003C\u002F",[45,122,101],{"class":78},[45,124,98],{"class":51},[45,126,127],{"class":78},"body",[45,129,130],{"class":51},"> \n",[45,132,134],{"class":47,"line":133},7,[45,135,136],{"class":51},"    Proxy Authentication Required \n",[45,138,140],{"class":47,"line":139},8,[45,141,142],{"emptyLinePlaceholder":19},"\n",[45,144,146],{"class":47,"line":145},9,[45,147,148],{"class":51},"This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.\n",[45,150,152,155,157,160,162],{"class":47,"line":151},10,[45,153,154],{"class":51},"\u003C\u002F",[45,156,127],{"class":78},[45,158,159],{"class":51},">\u003C\u002F",[45,161,40],{"class":78},[45,163,109],{"class":51},[45,165,167],{"class":47,"line":166},11,[45,168,169],{"class":51},"at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel) at\n",[45,171,173],{"class":47,"line":172},12,[45,174,175],{"class":51},"Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel) at\n",[45,177,179],{"class":47,"line":178},13,[45,180,181],{"class":51},"Microsoft.IdentityModel.Protocols.ConfigurationManager1.GetConfigurationAsync(CancellationToken cancel) --- \n",[45,183,185],{"class":47,"line":184},14,[45,186,187],{"class":51},"End of inner exception stack trace --- at\n",[45,189,191],{"class":47,"line":190},15,[45,192,193],{"class":51},"Microsoft.IdentityModel.Protocols.ConfigurationManager1.GetConfigurationAsync(CancellationToken cancel) at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler\n",[45,195,197],{"class":47,"line":196},16,[45,198,199],{"class":51},".HandleChallengeAsyncInternal(AuthenticationProperties properties) at\n",[45,201,203],{"class":47,"line":202},17,[45,204,205],{"class":51},"Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler.HandleChallengeAsync(AuthenticationProperties properties) at\n",[45,207,209],{"class":47,"line":208},18,[45,210,211],{"class":51},"Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.ChallengeAsync(AuthenticationProperties properties) at Microsoft.AspNetCore.Authentication.AuthenticationService.ChallengeAsync(HttpContext context, String scheme, AuthenticationProperties properties) at\n",[45,213,215],{"class":47,"line":214},19,[45,216,217],{"class":51},"Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at\n",[45,219,221],{"class":47,"line":220},20,[45,222,223],{"class":51},"Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at\n",[45,225,227,230,234],{"class":47,"line":226},21,[45,228,229],{"class":51},"Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.\u003C",[45,231,233],{"class":232},"s7hpK","Invoke",[45,235,236],{"class":51},">g__Awaited|(ExceptionHandlerMiddleware middleware, HttpContext context,\n",[238,239,241],"h4",{"id":240},"solution","Solution",[32,243,244],{},"Adding the following (for now solved this issue)",[36,246,250],{"className":247,"code":248,"language":249,"meta":11,"style":11},"language-cs shiki shiki-themes github-light github-dark",".AddOpenIdConnect(\"oidc\", options =>  { \n    options.BackchannelHttpHandler = new HttpClientHandler { \n    UseProxy = false, \n    UseDefaultCredentials = true \n }; \n","cs",[42,251,252,257,262,267,272],{"__ignoreMap":11},[45,253,254],{"class":47,"line":48},[45,255,256],{},".AddOpenIdConnect(\"oidc\", options =>  { \n",[45,258,259],{"class":47,"line":12},[45,260,261],{},"    options.BackchannelHttpHandler = new HttpClientHandler { \n",[45,263,264],{"class":47,"line":60},[45,265,266],{},"    UseProxy = false, \n",[45,268,269],{"class":47,"line":66},[45,270,271],{},"    UseDefaultCredentials = true \n",[45,273,274],{"class":47,"line":72},[45,275,276],{}," };\n",[278,279,280],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s7hpK, html code.shiki .s7hpK{--shiki-default:#B31D28;--shiki-default-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":11,"searchDepth":12,"depth":12,"links":282},[],"2020-04-09T16:52:26.395Z","While working through setup and configuration of Identity Server 4, I came across this authentication proxy issue.  Maybe this will help you out.","\u002Farticles\u002Fimages\u002Fopenidconnect.png",{},"\u002Farticles\u002Fopenidconnect-proxy-authentication-required",{"title":27,"description":284},"articles\u002Fopenidconnect-proxy-authentication-required",[18,291,292],"authentication","openid","BUI49bXPepv-NCmQ8IZtCDnHIgylvqx-CIRegHnSAtw",{"id":295,"title":296,"author":28,"body":297,"createdAt":342,"description":343,"extension":15,"img":313,"meta":344,"navigation":19,"path":345,"seo":346,"stem":347,"tags":348,"updatedAt":342,"__hash__":351},"articles\u002Farticles\u002Fyour-connection-is-not-private-google-chrome.md","Your connection is not private–Google Chrome",{"type":8,"value":298,"toc":340},[299,302,317,324,327,337],[32,300,301],{},"Seen1 this \"Your connection is not private” while working with https on your localhost (workstation).",[32,303,304],{},[305,306,308],"a",{"href":307},"\u002Farticles\u002Fimages\u002Fimage_637206600346445330.png",[309,310],"img",{"style":311,"title":312,"src":313,"alt":312,"width":314,"height":315,"border":316},"border: 0px currentcolor; display: inline; background-image: none;","image","\u002Farticles\u002Fimages\u002Fimage_thumb_637206600347776935.png",497,433,0,[32,318,319,320,323],{},"In Chrome, put in chrome:\u002F\u002Fflags\u002F#allow-insecure-localhost in the address bar.",[321,322],"br",{},"\nEnable the option that says \"Allow invalid certificates for resources loaded from localhost\".",[32,325,326],{},"Restart Chrome, and it should allow the site.",[32,328,329],{},[305,330,332],{"href":331},"\u002Farticles\u002Fimages\u002Fimage_637206600348897864.png",[309,333],{"style":311,"title":312,"src":334,"alt":312,"width":335,"height":336,"border":316},"\u002Farticles\u002Fimages\u002Fimage_thumb_637206600350111622.png",499,79,[32,338,339],{},"Worked like a charm!",{"title":11,"searchDepth":12,"depth":12,"links":341},[],"2020-03-24T15:20:35.123Z","Working local, working with https? Got your desktop environment working well, however while using Chrome and browsing you get this \"not private\" error.  You can continue working\u002Fbrowsing if you click through advanced and proceed.  This is great but if you are reading this my bet you are looking for a better solution.  Read on!",{},"\u002Farticles\u002Fyour-connection-is-not-private-google-chrome",{"title":296,"description":343},"articles\u002Fyour-connection-is-not-private-google-chrome",[349,350,18],"angular","vuejs","gHd-_VYIEkDSYbxkw6rXref1-CvJ-95vU8g6QOgK9qc",{"id":353,"title":354,"author":28,"body":355,"createdAt":479,"description":480,"extension":15,"img":427,"meta":481,"navigation":19,"path":482,"seo":483,"stem":484,"tags":485,"updatedAt":479,"__hash__":488},"articles\u002Farticles\u002Fancm-in-process-start-failure-shenanigans.md","ANCM InProcess Start Failure Shenanigans",{"type":8,"value":356,"toc":477},[357,365,390,398,407,410,415,417,430,433,458,461,464,474],[32,358,359,360,364],{},"If you are using .NET Core and have not received the following error\u002Fexception message I will send you $1.00.  Let me know!  ",[361,362,363],"b",{},"HTTP Error 500.30 - ANCM In-Process Start Failure","\nCommon solutions to this issue:",[366,367,368,372,375,381,384,387],"ul",{},[369,370,371],"li",{},"The application failed to start",[369,373,374],{},"The application started but then stopped",[369,376,377,378],{},"The application started but threw an exception during startup   ",[361,379,380],{},"Troubleshooting steps:",[369,382,383],{},"Check the system event log for error messages",[369,385,386],{},"Enable logging the application process' stdout messages",[369,388,389],{},"Attach a debugger to the application process and inspect",[32,391,392,393,397],{},"I have ran into this plenty of times already.  There are many reasons but at it’s root dotnet is not able to start up for one of many reasons.  As I run into my issues I will update this post with them.  So far, with ASP.NET Core 3.1.1  1. The IIS Application Pool – Advanced Settings “Enable 32-Bit Applications” – ",[394,395,396],"strong",{},"setting to False fixed my issue ","(this site was deployed to an on-premise IIS Server)  2. Azure installation – It was more difficult to identify the source of the issue as I was not working directly with IIS (Internet Information Server).  I first tried logging via App Service Logs,  and view the streaming logs which led me to error message similar to..",[32,399,400,406],{},[401,402,403,404],"em",{},"”IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.\u003C\u002Fli>     \u003Cli>IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.”",[321,405],{},"\nI then worked towards running the web application from command line to hope it gave me more information.\ni.e. Diagnostic Console – Debug Console then running the web assembly via “dotnet web.dll” (in this case my application was called Web). ",[32,408,409],{},"This gave me a much better startup.cs issue. I had good sense to recognize the issue\u002Fexception was within my startup class. \nI had my first real clue from the following message…",[32,411,412],{},[401,413,414],{},"”Unhandled exception. System.IO.DirectoryNotFoundException: D:\\home\\site\\wwwroot\\Scripts\\ at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters) at\nMicrosoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root) at Web.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider, LinkGenerator lin”",[401,416],{},[32,418,419],{},[401,420,421],{},[305,422,424],{"href":423},"\u002Farticles\u002Fimages\u002Fimage_637160171567190817.png",[309,425],{"title":312,"style":426,"border":316,"alt":312,"src":427,"width":428,"height":429},"border: 0px currentcolor; border-image: none; display: inline; background-image: none;","\u002Farticles\u002Fimages\u002Fimage_thumb_637160171568626232.png",722,343,[32,431,432],{},"I had used in prior 2.1 Core solution a scripts static directly which did not exist with this 3.1 solution.",[36,434,436],{"className":247,"code":435,"language":249,"meta":11,"style":11},"app.UseStaticFiles(new StaticFileOptions   {    \nFileProvider = new PhysicalFileProvider\n(Path.Combine(Directory.GetCurrentDirectory(), \"Scripts\")),\nRequestPath = \"\u002FScripts\" });\n",[42,437,438,443,448,453],{"__ignoreMap":11},[45,439,440],{"class":47,"line":48},[45,441,442],{},"app.UseStaticFiles(new StaticFileOptions   {    \n",[45,444,445],{"class":47,"line":12},[45,446,447],{},"FileProvider = new PhysicalFileProvider\n",[45,449,450],{"class":47,"line":60},[45,451,452],{},"(Path.Combine(Directory.GetCurrentDirectory(), \"Scripts\")),\n",[45,454,455],{"class":47,"line":66},[45,456,457],{},"RequestPath = \"\u002FScripts\" });\n",[32,459,460],{},"Once I removed this reference to \u002FScripts things worked and I was up and running. ",[32,462,463],{},"So, just note that this ANCM error is pretty good indication that something is wrong with Startup.cs class and so you really will be looking for logs for some indication as to what.",[32,465,466],{},[305,467,469],{"href":468},"\u002Farticles\u002Fimages\u002Fimage_637160171569717383.png",[309,470],{"title":312,"style":426,"border":316,"alt":312,"src":471,"width":472,"height":473},"\u002Farticles\u002Fimages\u002Fimage_thumb_637160171570874206.png",534,256,[278,475,476],{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":11,"searchDepth":12,"depth":12,"links":478},[],"2020-01-30T21:39:17.213Z","Common issue with .net core solutions when you deploy to a server and get ANCM In-Process failures",{},"\u002Farticles\u002Fancm-in-process-start-failure-shenanigans",{"title":354,"description":480},"articles\u002Fancm-in-process-start-failure-shenanigans",[486,487,18],"azure","aspnet","uO_1neDf1NscBqxD75q-Jvy9EuQmMV849La98mkWnks",{"id":490,"title":491,"author":28,"body":492,"createdAt":546,"description":547,"extension":15,"img":28,"meta":548,"navigation":19,"path":549,"seo":550,"stem":551,"tags":552,"updatedAt":546,"__hash__":553},"articles\u002Farticles\u002Fdatetimeoffset-confusion.md","DateTimeOffset Confusion",{"type":8,"value":493,"toc":544},[494,507,514,517,524,527,541],[32,495,496,497,500,501,503,504,506],{},"Consider the following timestamp: ",[394,498,499],{},"1995-07-14T13:05:00.0000000-03:00",".",[321,502],{},"\nWhen asked what the -03:00 at the end is called, many developers answer, “a time zone.”",[321,505],{},"\nWell…",[32,508,509,510,513],{},"The -03:00 does represent the offset from UTC.\nTo get the UTC time, ",[394,511,512],{},"invert"," the offset sign then add it to the time such as 13:05 + 3 = 16:05 in UTC.",[32,515,516],{},"Okay, following this ok now more details..",[32,518,519,520,523],{},"The ",[394,521,522],{},"mistake ","is in thinking that the offset is all there is to a time zone. Nope.",[32,525,526],{},"A time zone is a geographical area, and it consists of many pieces of information, such as",[366,528,529,532,535,538],{},[369,530,531],{},"One or more offsets. (DST is a thing, after all.)",[369,533,534],{},"The dates when DST transitions happen. (These can and do change whenever governments feel like it.)",[369,536,537],{},"The amount of time applied when transitions happened. (It’s not one hour everywhere.)",[369,539,540],{},"The historical records of changes to the above rules.",[32,542,543],{},"In short, is is not possible to establish the time zone by the offset!",{"title":11,"searchDepth":12,"depth":12,"links":545},[],"2019-12-11T14:02:13.400Z","For many years, dates, times, time zones, new language date types such as datetimeoffset have confused developers.  I am writing this in hopes that you can refresh some details about the often used datetimeoffset type.",{},"\u002Farticles\u002Fdatetimeoffset-confusion",{"title":491,"description":547},"articles\u002Fdatetimeoffset-confusion",[18],"zG8xVy_DOEaTRfDorK1eSmB3Hsgh4_eKm67fJnLbiak",{"id":555,"title":556,"author":28,"body":557,"createdAt":685,"description":686,"extension":15,"img":687,"meta":688,"navigation":19,"path":689,"seo":690,"stem":691,"tags":692,"updatedAt":685,"__hash__":694},"articles\u002Farticles\u002Fstring-comparisons.md","String Comparisons",{"type":8,"value":558,"toc":683},[559,562,566,573,577,583,587,593,597,603,607,613,617,626,629,642,670,681],[32,560,561],{},"In .NET there are 6 ways to compare strings.  Really? Why is it so difficult?",[238,563,565],{"id":564},"ordinal","Ordinal",[32,567,568,569,572],{},"Performs a simple byte comparison that is independent of language. This is most appropriate when comparing strings that are generated programmatically or ",[394,570,571],{},"when comparing case-sensitive resources"," such as passwords.",[238,574,576],{"id":575},"ordinalignorecase","OrdinalIgnoreCase",[32,578,579,580,500],{},"Treats the characters in the strings to compare as if they were converted to uppercase using the conventions of the invariant culture, and then performs a simple byte comparison that is independent of language. This is most appropriate when comparing strings that are generated programmatically or when",[394,581,582],{}," comparing case-insensitive resources such as paths and filenames",[238,584,586],{"id":585},"invariantculture","InvariantCulture",[32,588,589,590,500],{},"Compares strings in a linguistically relevant manner, but it is not suitable for display in any particular culture. Its",[394,591,592],{}," major application is to order strings in a way that will be identical across cultures",[238,594,596],{"id":595},"invariantcultureignorecase","InvariantCultureIgnoreCase",[32,598,599,600,500],{},"Compares strings in a linguistically relevant manner that ignores case, but it is not suitable for display in any particular culture. Its major application is to ",[394,601,602],{},"order strings in a way that will be identical across cultures",[238,604,606],{"id":605},"currentculture","CurrentCulture",[32,608,609,610],{},"Can be used when strings are linguistically relevant. For example, if strings are displayed to the user, or if strings are the result of user interaction,",[394,611,612],{}," culture-sensitive string comparison should be used to order the string data.",[238,614,616],{"id":615},"currentcultureignorecase","CurrentCultureIgnoreCase",[32,618,619,620,500,623,625],{},"Can be used when strings are linguistically relevant but their case is not. For example, if strings are displayed to the user but case is unimportant, culture-sensitive, ",[394,621,622],{},"case-insensitive string comparison should be used to order the string data",[321,624],{},"\nTip: You should always specify explicitly the comparer as the default value is not consistent.",[32,627,628],{},"For instance,",[32,630,631,634,635,638,639,641],{},[42,632,633],{},"string.IndexOf"," uses the current culture whereas ",[42,636,637],{},"string.Equals"," uses Ordinal.",[321,640],{},"\ni.e.",[36,643,645],{"className":247,"code":644,"language":249,"meta":11,"style":11},"string.Equals(\"\", \"\", StringComparison.Ordinal); \n\nnew [] { \"\" }.Contains(\"\", StringComparer.Ordinal); \n\nnew Dictionary(StringComparer.Ordinal); \n\n",[42,646,647,652,656,661,665],{"__ignoreMap":11},[45,648,649],{"class":47,"line":48},[45,650,651],{},"string.Equals(\"\", \"\", StringComparison.Ordinal); \n",[45,653,654],{"class":47,"line":12},[45,655,142],{"emptyLinePlaceholder":19},[45,657,658],{"class":47,"line":60},[45,659,660],{},"new [] { \"\" }.Contains(\"\", StringComparer.Ordinal); \n",[45,662,663],{"class":47,"line":66},[45,664,142],{"emptyLinePlaceholder":19},[45,666,667],{"class":47,"line":72},[45,668,669],{},"new Dictionary(StringComparer.Ordinal);\n",[32,671,672,673,680],{},"Refer to ",[305,674,679],{"href":675,"target":676,"rel":677},"https:\u002F\u002Fwww.meziantou.net\u002Fstring-comparisons-are-harder-than-it-seems.htm","_blank",[678],"noopener","blog"," for additional samples and Rosyln analyzer to help with coding within your IDE.",[278,682,476],{},{"title":11,"searchDepth":12,"depth":12,"links":684},[],"2019-12-10T17:37:51.332Z","Yes! There really are 6 ways to compare strings within .NET (I suspect other languages as well).  Hopefully this will shed some light on the options.","\u002Farticles\u002Fimages\u002FgzWyiS6VDt.png",{},"\u002Farticles\u002Fstring-comparisons",{"title":556,"description":686},"articles\u002Fstring-comparisons",[18,693],"sql","Ib87YXw71UKKaBTOHX5m6SHBrTG_PcVtHJ-LK6igPl0",{"id":696,"title":697,"author":28,"body":698,"createdAt":1025,"description":1026,"extension":15,"img":740,"meta":1027,"navigation":19,"path":1028,"seo":1029,"stem":1030,"tags":1031,"updatedAt":1025,"__hash__":1032},"articles\u002Farticles\u002Faspnet-core-3-things-i-learned-pro-tips-migration-to-aspnet-core-3.md","ASP.NET Core 3 Things I Learned \u002F Pro Tips \u002F Migration to ASP.NET Core 3",{"type":8,"value":699,"toc":1023},[700,732,743,751,754,863,878,884,909,932,937,942,956,1021],[366,701,702,708,711,714,717,720,723,726,729],{},[369,703,704,705],{},"Starting up the web application with ",[394,706,707],{},"dotnet run",[369,709,710],{},"there are CLI parameters that you can use to set environment, port etc.",[369,712,713],{},"uses Kestrel to host the application",[369,715,716],{},"windows authentication cannot be turned on with dotnet run",[369,718,719],{},"can configure default behavior from within Visual Studio project properties",[369,721,722],{},"Debug, select Launch “Project” then you can set the App Url, default page, etc.",[369,724,725],{},"Hitting debug F5 within Visual Studio when the {Project Name} profile is selected hosts the application on Kestrel similar to dotnet run",[369,727,728],{},"dotnet run –e development will set the environment variable to ‘production’ (",[369,730,731],{},"in the following image you can see that I set the default environment for Kestrel runs to Development",[32,733,734,735],{},"ASPNETCORE_ENVIRONMENT Development\n",[305,736,738],{"href":737},"\u002Farticles\u002Fimages\u002Fimage_637115214952391737.png",[309,739],{"style":311,"title":312,"src":740,"alt":312,"width":741,"height":742,"border":316},"\u002Farticles\u002Fimages\u002Fimage_thumb_637115214953620084.png",545,336,[366,744,745,748],{},[369,746,747],{},"JSON properties are now lower case in asp.net core (i.e. when return json from a method Json({object here}) would have all properties changed to lower case)",[369,749,750],{},"use the following code to avoid camel case names by default \nservices.AddControllersWithViews()\n       .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());",[32,752,753],{},"{\"Id\":9000,\"FullName\":\"John Smith\"} would be serialized to {\"id\":9000,\"fullName\":\"John Smith\"}       ",[366,755,756,765,768,775,830,847,856],{},[369,757,758,759,764],{},"Debug ASP.NET Core apps in Visual Studio IIS\u002FIISExpress etc. reference ",[305,760,763],{"href":761,"target":676,"rel":762},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fvisualstudio\u002Fdebugger\u002Fhow-to-enable-debugging-for-aspnet-applications?view=vs-2019",[678],"here","        ",[369,766,767],{},"After setting a application within IIS, setting authentication to windows, selecting application pool with no managed code – you may get the following…\nThe in process request handler, Microsoft.AspNetCore.Server.IIS, was not referenced in the application.",[369,769,770],{},[305,771,774],{"href":772,"target":676,"rel":773},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Fhost-and-deploy\u002Fiis\u002F?view=aspnetcore-2.2",[678],"Host ASP.NET Core on Windows with IIS",[369,776,777,778,781,785],{},"In order to ready http request bodies in a synchronous manner I had to add following service configuration\n",[305,779],{"href":780},"https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F47735133\u002Fasp-net-core-synchronous-operations-are-disallowed-call-writeasync-or-set-all",[305,782,780],{"href":780,"rel":783},[784],"nofollow",[36,786,788],{"className":247,"code":787,"language":249,"meta":11,"style":11},"\u002F\u002F If using Kestrel: \n\u002F\u002Fservices.Configure&lt;KestrelServerOptions>(options => \n\u002F\u002F{ \n\u002F\u002Foptions.AllowSynchronousIO = true; \n\u002F\u002F});\n\u002F\u002F If using IIS: \nservices.Configure > IISServerOptions>(options => { \noptions.AllowSynchronousIO = true; })  \n",[42,789,790,795,800,805,810,815,820,825],{"__ignoreMap":11},[45,791,792],{"class":47,"line":48},[45,793,794],{},"\u002F\u002F If using Kestrel: \n",[45,796,797],{"class":47,"line":12},[45,798,799],{},"\u002F\u002Fservices.Configure&lt;KestrelServerOptions>(options => \n",[45,801,802],{"class":47,"line":60},[45,803,804],{},"\u002F\u002F{ \n",[45,806,807],{"class":47,"line":66},[45,808,809],{},"\u002F\u002Foptions.AllowSynchronousIO = true; \n",[45,811,812],{"class":47,"line":72},[45,813,814],{},"\u002F\u002F});\n",[45,816,817],{"class":47,"line":112},[45,818,819],{},"\u002F\u002F If using IIS: \n",[45,821,822],{"class":47,"line":133},[45,823,824],{},"services.Configure > IISServerOptions>(options => { \n",[45,826,827],{"class":47,"line":139},[45,828,829],{},"options.AllowSynchronousIO = true; })\n",[369,831,832,833,838,839],{},"dotnet – info Shows what versions are installed on your workstation (",[305,834,837],{"href":835,"target":676,"rel":836},"https:\u002F\u002Fweblog.west-wind.com\u002Fposts\u002F2018\u002FJun\u002F05\u002FWhich-NET-Core-Runtime-Download-do-you-need",[678],"Reference Rick Strahl",")\n",[305,840,842],{"href":841},"\u002Farticles\u002Fimages\u002Fimage_637115214954889487.png",[309,843],{"style":311,"title":312,"src":844,"alt":312,"width":845,"height":846,"border":316},"\u002Farticles\u002Fimages\u002Fimage_thumb_637115214956154680.png",353,206,[369,848,849,850,853],{},"This looks really interesting but I have yet to install\u002Ftry it out Live Reload using dotnet watch ",[305,851],{"href":852},"https:\u002F\u002Fweblog.west-wind.com\u002Fposts\u002F2019\u002FJun\u002F03\u002FBuilding-Live-Reload-Middleware-for-ASPNET-Core",[305,854,852],{"href":852,"rel":855},[784],[369,857,858,859,862],{},"IHostBuilder vs IWebHostBuilder – ASP.NET Core is used to build http endpoints using Kestrel web server. \nIWebHostbuilder ",[394,860,861],{},"remains for backward compatibility only",", and was used to encapsulate DI, Logging and configuration.  This was used in earlier versions of ASP.NET Core 3 for http workloads.",[32,864,865,866,871,872,877],{},"The default .NET Core 3 ASP.NET Core template sets up by default in the program.cs IHostBuilder, which is the ",[305,867,870],{"href":868,"target":676,"rel":869},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fhost\u002Fweb-host?view=aspnetcore-3.1",[678],"recommended"," for all app types.  Documentation can be found at ",[305,873,876],{"href":874,"target":676,"rel":875},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fhost\u002Fgeneric-host?view=aspnetcore-3.1",[678],"docs.microsoft.com",".  A host can encapsulates dependency injection, logging, configuration, IHostedService implementations.  Hosting is no longer bound to Kestrel and no longer bound to ASP.NET Core (oddly, this means you can start a host that doesn’t require Kestrel and doesn’t even need the ASP.NET Core Framework)",[32,879,880,883],{},[394,881,882],{},"CreateHostBuilder"," has the following defaults",[366,885,886,898,901],{},[369,887,888,889,893,894,500],{},"Sets the ",[305,890,892],{"href":891},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Findex?view=aspnetcore-3.1#content-root","content root"," to the path returned by ",[305,895,897],{"href":896},"https:\u002F\u002Fdocs.microsoft.com\u002Fdotnet\u002Fapi\u002Fsystem.io.directory.getcurrentdirectory","GetCurrentDirectory",[369,899,900],{},"Loads host configuration from:\n----- Environment variables prefixed with \"DOTNET_\".\n----- Command-line arguments.",[369,902,903,904,908],{},"Loads app configuration from:\n----- appsettings.json.\n----- appsettings.{Environment}.json.\n----- ",[305,905,907],{"href":906},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Fsecurity\u002Fapp-secrets?view=aspnetcore-3.1","Secret Manager"," when the app runs in the Development environment.\n----- Environment variables.\n----- Command-line arguments.",[366,910,911,919],{},[369,912,913,914,918],{},"Adds the following ",[305,915,917],{"href":916},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Flogging\u002Findex?view=aspnetcore-3.1","logging"," providers:\n----- Console\n----- Debug\n----- EventSource\n----- EventLog (only when running on Windows)",[369,920,921,922,926,927,931],{},"Enables ",[305,923,925],{"href":924},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fdependency-injection?view=aspnetcore-3.1#scope-validation","scope validation"," and ",[305,928,930],{"href":929},"https:\u002F\u002Fdocs.microsoft.com\u002Fdotnet\u002Fapi\u002Fmicrosoft.extensions.dependencyinjection.serviceprovideroptions.validateonbuild#Microsoft_Extensions_DependencyInjection_ServiceProviderOptions_ValidateOnBuild","dependency validation"," when the environment is Development.",[32,933,934],{},[394,935,936],{},"ConfigureWebHostDefaults ",[366,938,939],{},[369,940,941],{},"Loads host configuration from environment variables prefixed with \"ASPNETCORE_\".",[366,943,944],{},[369,945,946,947,951,952,500],{},"Sets ",[305,948,950],{"href":949},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fservers\u002Fkestrel?view=aspnetcore-3.1","Kestrel"," server as the web server and configures it using the app's hosting configuration providers. For the Kestrel server's default options, see ",[305,953,955],{"href":954},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fservers\u002Fkestrel?view=aspnetcore-3.1#kestrel-options","Kestrel web server implementation in ASP.NET Core",[366,957,958,965,972,978,986,992,995,1004,1013],{},[369,959,960,961,500],{},"Adds ",[305,962,964],{"href":963},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fservers\u002Fkestrel?view=aspnetcore-3.1#host-filtering","Host Filtering middleware",[369,966,960,967,971],{},[305,968,970],{"href":969},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Fhost-and-deploy\u002Fproxy-load-balancer?view=aspnetcore-3.1#forwarded-headers","Forwarded Headers middleware"," if ASPNETCORE_FORWARDEDHEADERS_ENABLED=true.",[369,973,974,975,500],{},"Enables IIS integration. For the IIS default options, see ",[305,976,774],{"href":977},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Fhost-and-deploy\u002Fiis\u002Findex?view=aspnetcore-3.1#iis-options",[369,979,980,981,985],{},"Configuration for Framework-provided services can be found ",[305,982,763],{"href":983,"target":676,"rel":984},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fhost\u002Fgeneric-host?view=aspnetcore-3.1#framework-provided-services",[678]," (any host lifetime, environment etc.)",[369,987,988,989],{},"Unable to resolve service for type 'Microsoft.Extensions.Logging.ILoggerFactory' while attempting to activate 'Web.Startup'. – ",[394,990,991],{},"Exception\n",[369,993,994],{},"the startup constructor use to look like public Startup(IConfiguration configuration, ILoggerFactory loggerFactory)",[369,996,997,998,1003],{},"new to ASP.NET Core 3 it is no longer possible to inject ILogger in Startup.cs and Program.cs (Reference: ",[305,999,1002],{"href":1000,"target":676,"rel":1001},"https:\u002F\u002Fgithub.com\u002Faspnet\u002FAnnouncements\u002Fissues\u002F353",[678],"Github",")",[369,1005,1006,1007,1012],{},"Another ",[305,1008,1011],{"href":1009,"target":676,"rel":1010},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fazure\u002Fazure-monitor\u002Fapp\u002Filogger#capture-ilogger-logs-from-startupcs-and-programcs-in-aspnet-core-apps",[678],"reference"," to this change specifically calls this out",[369,1014,1015,1016],{},"Changes with ASP.NET Core 3 to Program.cs \u002F Startup.cs\nReference: ",[305,1017,1020],{"href":1018,"target":676,"rel":1019},"https:\u002F\u002Fandrewlock.net\u002Fexploring-the-new-project-file-program-and-the-generic-host-in-asp-net-core-3\u002F",[678],"Andrew Lock",[278,1022,476],{},{"title":11,"searchDepth":12,"depth":12,"links":1024},[],"2019-12-09T20:51:35.746Z","Moving from ASP.NET Core 2 to ASP.NET 3 (Migration) there were a number of 'things' I picked up and decided I would document as I moved through the application.  New Program.cs and Startup.cs changes, new logging configuration changes, and default ASP.NET Core tips included.",{},"\u002Farticles\u002Faspnet-core-3-things-i-learned-pro-tips-migration-to-aspnet-core-3",{"title":697,"description":1026},"articles\u002Faspnet-core-3-things-i-learned-pro-tips-migration-to-aspnet-core-3",[18],"w0iFgfavvdV8-1UR0gCTw4qVYXmyAzFa1CYkep7Rz8M",{"id":1034,"title":1035,"author":28,"body":1036,"createdAt":1177,"description":1178,"extension":15,"img":28,"meta":1179,"navigation":19,"path":1180,"seo":1181,"stem":1182,"tags":1183,"updatedAt":1177,"__hash__":1184},"articles\u002Farticles\u002Faspnet-core-slow-start-up.md","ASP.NET CORE–Slow Start Up",{"type":8,"value":1037,"toc":1175},[1038,1041,1130,1133,1163,1172],[32,1039,1040],{},"I was trying to determine why my asp.net core application as so slow during startup (F5 w\u002Fdebugging).\nI believe I found one of the reasons.\nBy default, a new asp.net core application has an appsettings.Development.json file. \nWithin this file there are several settings to set the default log level.  Typically, you will see something like the following",[36,1042,1046],{"className":1043,"code":1044,"language":1045,"meta":11,"style":11},"language-json shiki shiki-themes github-light github-dark","{ \n\"Logging\": \n    { \n        \"LogLevel\": \n        {  \n            \"Default\": \"Debug\", \n            \"System\": \"Information\", \n            \"Microsoft\": \"Information\"\n        } \n    }  \n}  \n","json",[42,1047,1048,1053,1062,1067,1074,1079,1093,1105,1115,1120,1125],{"__ignoreMap":11},[45,1049,1050],{"class":47,"line":48},[45,1051,1052],{"class":51},"{ \n",[45,1054,1055,1059],{"class":47,"line":12},[45,1056,1058],{"class":1057},"sj4cs","\"Logging\"",[45,1060,1061],{"class":51},": \n",[45,1063,1064],{"class":47,"line":60},[45,1065,1066],{"class":51},"    { \n",[45,1068,1069,1072],{"class":47,"line":66},[45,1070,1071],{"class":1057},"        \"LogLevel\"",[45,1073,1061],{"class":51},[45,1075,1076],{"class":47,"line":72},[45,1077,1078],{"class":51},"        {  \n",[45,1080,1081,1084,1087,1090],{"class":47,"line":112},[45,1082,1083],{"class":1057},"            \"Default\"",[45,1085,1086],{"class":51},": ",[45,1088,1089],{"class":89},"\"Debug\"",[45,1091,1092],{"class":51},", \n",[45,1094,1095,1098,1100,1103],{"class":47,"line":133},[45,1096,1097],{"class":1057},"            \"System\"",[45,1099,1086],{"class":51},[45,1101,1102],{"class":89},"\"Information\"",[45,1104,1092],{"class":51},[45,1106,1107,1110,1112],{"class":47,"line":139},[45,1108,1109],{"class":1057},"            \"Microsoft\"",[45,1111,1086],{"class":51},[45,1113,1114],{"class":89},"\"Information\"\n",[45,1116,1117],{"class":47,"line":145},[45,1118,1119],{"class":51},"        } \n",[45,1121,1122],{"class":47,"line":151},[45,1123,1124],{"class":51},"    }  \n",[45,1126,1127],{"class":47,"line":166},[45,1128,1129],{"class":51},"}\n",[32,1131,1132],{},"Keep in mind the order of settings are as follows going from very verbose to turned off.",[366,1134,1135,1138,1141,1144,1147,1150,1153],{},[369,1136,1137],{},"Trace (Very Verbose)",[369,1139,1140],{},"Debug",[369,1142,1143],{},"Information",[369,1145,1146],{},"Warning",[369,1148,1149],{},"Error",[369,1151,1152],{},"Critical",[369,1154,1155,1156,1158,1159,1162],{},"None",[321,1157],{},"\nI found that setting my development log settings to anything above Warning improved startup up time ",[394,1160,1161],{},"significantly","!",[32,1164,1165,1166,1171],{},"After I figured out above I did come across a Rick Strahl ",[305,1167,1170],{"href":1168,"target":676,"rel":1169},"https:\u002F\u002Fweblog.west-wind.com\u002Fposts\u002F2018\u002FDec\u002F31\u002FDont-let-ASPNET-Core-Default-Console-Logging-Slow-your-App-down#summary",[678],"post",".  If you don’t follow Rick do.",[278,1173,1174],{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":11,"searchDepth":12,"depth":12,"links":1176},[],"2019-12-08T03:45:40.058Z","In an effort to speed up my development process, I determined that changing the logging level, even in development made a huge difference.  Keep this in mind, and let me know if you find this useful.",{},"\u002Farticles\u002Faspnet-core-slow-start-up",{"title":1035,"description":1178},"articles\u002Faspnet-core-slow-start-up",[18],"Q1_YJbQEIsPuw5Us9AG0sFQVIpdMJzmtaPXHFL-GQ80",{"id":1186,"title":1187,"author":1188,"body":1189,"createdAt":1276,"description":1277,"extension":15,"img":28,"meta":1278,"navigation":19,"path":1279,"seo":1280,"stem":1281,"tags":1282,"updatedAt":1276,"__hash__":1283},"articles\u002Farticles\u002Fhttpclient-saga--related-noteslinks.md","HttpClient Saga and Related Notes Links","[object Object]",{"type":8,"value":1190,"toc":1274},[1191,1206,1222,1225,1236,1239,1254,1257,1260,1267],[32,1192,1193,1194,1197,1198,1202,1203],{},"On ",[394,1195,1196],{},".Net Full framework",", you can control the number of outgoing client connections by setting ",[305,1199,1201],{"href":1200},"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. ",[394,1204,1205],{},"It is 2 by default.",[32,1207,1193,1208,1211,1212,1216,1217,1221],{},[394,1209,1210],{},".Net Core",", you can set it by changing ",[305,1213,1215],{"href":1214},"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 ",[305,1218,1220],{"href":1219},"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",[32,1223,1224],{},"References:",[32,1226,1227,1231,1232,1234],{},[305,1228,1230],{"href":1200,"target":676,"rel":1229},[678],"ServicePointManager"," ",[321,1233],{},[305,1235,1215],{"href":1214},[32,1237,1238],{},"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.",[32,1240,1241,1231,1246,1231,1248,1250,1251,1253],{},[305,1242,1245],{"href":1243,"target":676,"rel":1244},"https:\u002F\u002Faspnetmonsters.com\u002F2016\u002F08\u002F2016-08-27-httpclientwrong\u002F",[678],"YOU'RE USING HTTPCLIENT WRONG AND IT IS DESTABILIZING YOUR SOFTWARE",[321,1247],{},[321,1249],{},"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. ",[321,1252],{},"Due to these issues, the HttpClientFactory was created.",[32,1255,1256],{},"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.",[32,1258,1259],{},"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.",[32,1261,1262],{},[305,1263,1266],{"href":1264,"target":676,"rel":1265},"http:\u002F\u002Fanthonygiretti.com\u002F2018\u002F09\u002F06\u002Fhow-to-unit-test-a-class-that-consumes-an-httpclient-with-ihttpclientfactory-in-asp-net-core\u002F",[678],"How to unit test a class that consumes an HttpClient with IHttpClientFactory in ASP.NET Core?",[32,1268,1269],{},[305,1270,1273],{"href":1271,"target":676,"rel":1272},"https:\u002F\u002Fcodereview.stackexchange.com\u002Fquestions\u002F227596\u002Fsimple-httpclient-usage-for-integration-tests-in-net-core",[678],"Integration Testing",{"title":11,"searchDepth":12,"depth":12,"links":1275},[],"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":1187,"description":1277},"articles\u002Fhttpclient-saga--related-noteslinks",[18],"l1pMNA9gO17s0hmcoHaNRdtKD9yGrQyXApQIDK9aZKI",{"id":1285,"title":1286,"author":28,"body":1287,"createdAt":1373,"description":1374,"extension":15,"img":1303,"meta":1375,"navigation":19,"path":1376,"seo":1377,"stem":1378,"tags":1379,"updatedAt":1373,"__hash__":1381},"articles\u002Farticles\u002Fattaching-to-net-debugger-wvisual-studio-aspnet-core.md","Attaching to .NET Debugger w\u002FVisual Studio ASP.NET Core",{"type":8,"value":1288,"toc":1371},[1289,1292,1314,1317,1321,1324,1327,1337,1340,1349,1352,1361],[32,1290,1291],{},"Attaching from within Visual Studio to the dotnet.exe process Debug – Attach to Process",[1293,1294,1295,1296,1295,1306,1295],"blockquote",{},"  \n",[305,1297,1299],{"href":1298},"\u002Farticles\u002Fimages\u002Fimage_thumb3_636794037223872773.png",[309,1300],{"style":1301,"title":1302,"src":1303,"alt":1302,"width":1304,"height":1305,"border":316},"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;","image_thumb3","\u002Farticles\u002Fimages\u002Fimage_thumb3_thumb_636794037227151161.png",166,244,[305,1307,1309],{"href":1308},"\u002Farticles\u002Fimages\u002Fimage_thumb4_636794037229825895.png",[309,1310],{"style":311,"title":1311,"src":1312,"alt":1311,"width":1305,"height":1313,"border":316},"image_thumb4","\u002Farticles\u002Fimages\u002Fimage_thumb4_thumb_636794037232542538.png",174,[1293,1315,1316],{},"  \nThis works fine, however to me seems too many clicks\u002Fsteps to do efficiently.  \n",[305,1318,1320],{"href":1319},"https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=arcticdev.AnotherAttachToAny","AnotherAttachToAny",[32,1322,1323],{},"Once installed, I then set keystroke shortcut keys to execute the above steps.  This is how it is currently configured to me.  You can see I have Alt-A setup to immediately attach to the w3process (IIS), and Alt-D attaches to dotnet.exe. ",[32,1325,1326],{},"This is one keystroke to attach to the running process and any breakpoints within my .net code are hit and I can then step through.",[32,1328,1329],{},[305,1330,1332],{"href":1331},"\u002Farticles\u002Fimages\u002Fimage_636794037234623240.png",[309,1333],{"style":1334,"title":312,"src":1335,"alt":312,"width":1305,"height":1336,"border":316},"margin: 0px; display: inline; background-image: none;","\u002Farticles\u002Fimages\u002Fimage_thumb_636794037237173898.png",62,[32,1338,1339],{},"Configuration of this extension is done through Tools – Options – Another Attach To Any",[32,1341,1342],{},[305,1343,1345],{"href":1344},"\u002Farticles\u002Fimages\u002Fimage_636794037240524929.png",[309,1346],{"style":1334,"title":312,"src":1347,"alt":312,"width":1305,"height":1348,"border":316},"\u002Farticles\u002Fimages\u002Fimage_thumb_636794037243711700.png",193,[32,1350,1351],{},"Setting up a keystroke to one of the above commands is done through Tools – Options – Keyboard",[32,1353,1354],{},[305,1355,1357],{"href":1356},"\u002Farticles\u002Fimages\u002Fimage_636794037246961946.png",[309,1358],{"style":1334,"title":312,"src":1359,"alt":312,"width":1305,"height":1360,"border":316},"\u002Farticles\u002Fimages\u002Fimage_thumb_636794037249700449.png",191,[32,1362,1363,1364],{},"This single extension has saved me hundreds of hours ",[309,1365],{"className":1366,"src":1369,"alt":1370},[1367,1368],"wlEmoticon","wlEmoticon-smile","\u002Farticles\u002Fimages\u002FwlEmoticon-smile_636794037251738341.png","Smile",{"title":11,"searchDepth":12,"depth":12,"links":1372},[],"2018-12-03T03:15:25.405Z","You have a website up and running, and now you want to connect the Visual Studio Debugger.  This is often the case if you do not start with F5 - Debug to start the browser and automatically attach to the .net debugger.  In reality, I almost never push F5.  Instead, I attach to the debugger on the fly with the approach below.  Take a moment to check it out.",{},"\u002Farticles\u002Fattaching-to-net-debugger-wvisual-studio-aspnet-core",{"title":1286,"description":1374},"articles\u002Fattaching-to-net-debugger-wvisual-studio-aspnet-core",[18,487,1380],"visualstudio","Nscy8wnaq8s7ro0UwOm6dGcZvHofFD7TMOQpO4pRHZs",{"id":1383,"title":1384,"author":28,"body":1385,"createdAt":1534,"description":1535,"extension":15,"img":1503,"meta":1536,"navigation":19,"path":1537,"seo":1538,"stem":1539,"tags":1540,"updatedAt":1534,"__hash__":1541},"articles\u002Farticles\u002Fvue-app-and-mvc-routing-wvisual-studio-aspnet-core.md","Vue App and MVC Routing w\u002FVisual Studio ASP.NET Core",{"type":8,"value":1386,"toc":1532},[1387,1390,1393,1399,1405,1419,1437,1464,1477,1526,1529],[32,1388,1389],{},"###What page is loaded on starting the application.",[32,1391,1392],{},"The default route for this VS.NET ASP.NET Core application is the public\u002Findex.html with the following setup in the Startup.cs",[32,1394,1395,1396,1398],{},"app.UseSpa(spa => { ",[321,1397],{}," spa.Options.SourcePath = \"ClientApp\";",[32,1400,1401,1402,1404],{}," if (env.IsDevelopment()) ",[321,1403],{}," {",[32,1406,1407,1408,1410,1411,1231,1413,1415,1416,1418],{}," \u002F\u002F run npm process with client app ",[321,1409],{}," spa.UseVueCli(npmScript: \"serve\", port: 8080); ",[321,1412],{},[321,1414],{}," } ",[321,1417],{}," }); ",[32,1420,1421,1424,1425,1428,1429,1432,1433,1436],{},[394,1422,1423],{},"If you have"," a HomeController and a Views\u002FHome\u002FIndex.cshtml view, \nwhen the application starts via F5 it will route by default to http:\u002F\u002Flocalhost:50557 ",[394,1426,1427],{},"or"," \n",[305,1430,1431],{"href":1431},"http:\u002F\u002Flocalhost:50557\u002Findex.html"," and if you want to navigate to your controller\u002Fview you can navigate to \n",[305,1434,1435],{"href":1435},"http:\u002F\u002Flocalhost:50557\u002FHome\u002FIndex"," Essentially it will default to the vue index.html page in this scenario.",[1293,1438,1439,1449,1452],{},[32,1440,1441],{},[305,1442,1444],{"href":1443},"\u002Farticles\u002Fimages\u002Fimage_thumb[1]_636791382475500953.png",[309,1445],{"style":1301,"title":1446,"src":1447,"alt":1446,"width":1305,"height":1448,"border":316},"image_thumb[1]","\u002Farticles\u002Fimages\u002Fimage_thumb[1]_thumb_636791382476448208.png",141,[32,1450,1451],{},"Navigating to http:\u002F\u002Flocalhost:50557\u002Fhome\u002Findex will navigate to the MVC view, however if you want this route to navigate the vue app you can add, \nwhich would redirect the user from the MVC view to the vue app again.",[32,1453,1454,1455,1457,1458,1460,1461,1463],{},"public IActionResult Index() ",[321,1456],{}," { ",[321,1459],{}," return Redirect(\"~\u002Findex.html\"); ",[321,1462],{}," }",[32,1465,1466,1468,1469,1472,1473,1476],{},[394,1467,1423],{}," a HomeController ",[394,1470,1471],{},"AND ","and you add ",[394,1474,1475],{},"MapSpaFallbackRoute"," reference within the Startup.cs similar to the following, starting via F5 the site will navigate to http:\u002F\u002Flocalhost:50557\u002F and land on the Views\u002FHome\u002FIndex.cshtml This really is the reverse of the above scenario. In this case it will default to the MVC view and you have to explicitly navigate to the \u002Findex.html for the vue app.",[1293,1478,1479,1491,1499,1509,1516],{},[32,1480,1481,1482,1484,1485,1487,1488,1490],{},"app.UseMvc(routes => { ",[321,1483],{}," routes.MapRoute( ",[321,1486],{}," name: \"default\", ",[321,1489],{}," template: \"{controller}\u002F{action=Index}\u002F{id?}\");",[32,1492,1231,1493,1231,1496,1498],{},[394,1494,1495],{},"routes.MapSpaFallbackRoute(\"spa-fallback\", new { controller = \"Home\", action = \"Index\" });",[321,1497],{},"});",[32,1500,1501],{},[305,1502,1504],{"href":1503},"\u002Farticles\u002Fimages\u002Fimage_thumb[2]_636791382477200018.png",[309,1505],{"style":1301,"title":1506,"src":1507,"alt":1506,"width":1305,"height":1508,"border":316},"image_thumb[2]","\u002Farticles\u002Fimages\u002Fimage_thumb[2]_thumb_636791382477864407.png",74,[32,1510,1511,1512,1515],{},"If you want to navigate to your vue app, you must ",[394,1513,1514],{},"explicitly"," reference http:\u002F\u002Flocalhost:50557\u002FIndex.html Any invalid routes will default to the Home\u002FIndex view.",[32,1517,1518],{},[305,1519,1521],{"href":1520},"https:\u002F\u002Fwww.davidyardy.com\u002FPosts\u002Ffiles\u002Fimage_thumb[3]_636791382478902143.png",[309,1522],{"style":1301,"title":1523,"src":1524,"alt":1523,"width":1305,"height":1525,"border":316},"image_thumb[3]","\u002Farticles\u002Fimages\u002Fimage_thumb[3]_thumb_636791382479671548.png",126,[32,1527,1528],{},"There are a number of combinations and can be confusing. \n",[32,1530,1531],{},"Primarily, both the vue app and MVC navigation work fine. It really just depends on if you want the MVC to be the default route, or the vue app index.html page.",{"title":11,"searchDepth":12,"depth":12,"links":1533},[],"2018-11-30T01:30:48.068Z","Vue.js SPA routing conflicts with MVC routing.  Short article reviewing the options, and an approach on how to get both working nicely together.",{},"\u002Farticles\u002Fvue-app-and-mvc-routing-wvisual-studio-aspnet-core",{"title":1384,"description":1535},"articles\u002Fvue-app-and-mvc-routing-wvisual-studio-aspnet-core",[350,18],"up2a1CH7j5uH_V7CzCVaVuAZueA1QSdo_Obd_kNIwWU",{"id":1543,"title":1544,"author":28,"body":1545,"createdAt":1808,"description":1549,"extension":15,"img":1743,"meta":1809,"navigation":19,"path":1810,"seo":1811,"stem":1812,"tags":1813,"updatedAt":1808,"__hash__":1814},"articles\u002Farticles\u002Fstarting-a-vue-app-wvisual-studio-aspnet-core-2.md","Starting a Vue App w\u002FVisual Studio ASP.NET Core 2",{"type":8,"value":1546,"toc":1806},[1547,1550,1553,1621,1634,1637,1681,1694,1725,1735,1745,1748,1751,1771,1774,1789,1792,1801,1804],[32,1548,1549],{},"I created my Vue project, included it with my ASP.NET Core project.  For more information reference my prior post on Vue with ASP.NET Core.",[32,1551,1552],{},"Significant to how the project starts\u002Fruns is the setup within Startup.cs",[36,1554,1556],{"className":247,"code":1555,"language":249,"meta":11,"style":11},"app.UseSpa(spa => {    \n    spa.Options.SourcePath =  \"ClientApp \";      \n    if (env.IsDevelopment())          \n    {              \n    \u002F\u002Fspa.UseReactDevelopmentServer(npmScript:  \"start \");          \n    \u002F\u002F run npm process with client app             \n    \u003Cstrong>spa.UseVueCli(npmScript:  \"serve \", port: 8080);\u003C\u002Fstrong>          \n    \u002F\u002F if you just prefer to proxy requests from client app, use proxy to SPA dev server instead, \u002F\u002F app should be already running before starting a .NET client:              \n    \u002F\u002F spa.UseProxyToSpaDevelopmentServer( \"\u003Ca href=\"http:\u002F\u002Flocalhost:8080 \");\">http:\u002F\u002Flocalhost:8080 \");\u003C\u002Fa> \n    \u002F\u002F your Vue app port\n    }\n});\n",[42,1557,1558,1563,1568,1573,1578,1583,1588,1593,1601,1606,1611,1616],{"__ignoreMap":11},[45,1559,1560],{"class":47,"line":48},[45,1561,1562],{},"app.UseSpa(spa => {    \n",[45,1564,1565],{"class":47,"line":12},[45,1566,1567],{},"    spa.Options.SourcePath =  \"ClientApp \";      \n",[45,1569,1570],{"class":47,"line":60},[45,1571,1572],{},"    if (env.IsDevelopment())          \n",[45,1574,1575],{"class":47,"line":66},[45,1576,1577],{},"    {              \n",[45,1579,1580],{"class":47,"line":72},[45,1581,1582],{},"    \u002F\u002Fspa.UseReactDevelopmentServer(npmScript:  \"start \");          \n",[45,1584,1585],{"class":47,"line":112},[45,1586,1587],{},"    \u002F\u002F run npm process with client app             \n",[45,1589,1590],{"class":47,"line":133},[45,1591,1592],{},"    \u003Cstrong>spa.UseVueCli(npmScript:  \"serve \", port: 8080);\u003C\u002Fstrong>          \n",[45,1594,1595,1598],{"class":47,"line":139},[45,1596,1597],{},"    \u002F\u002F if you just prefer to proxy requests from client app, use proxy to SPA dev server instead,",[45,1599,1600],{}," \u002F\u002F app should be already running before starting a .NET client:              \n",[45,1602,1603],{"class":47,"line":145},[45,1604,1605],{},"    \u002F\u002F spa.UseProxyToSpaDevelopmentServer( \"\u003Ca href=\"http:\u002F\u002Flocalhost:8080 \");\">http:\u002F\u002Flocalhost:8080 \");\u003C\u002Fa> \n",[45,1607,1608],{"class":47,"line":151},[45,1609,1610],{},"    \u002F\u002F your Vue app port\n",[45,1612,1613],{"class":47,"line":166},[45,1614,1615],{},"    }\n",[45,1617,1618],{"class":47,"line":172},[45,1619,1620],{},"});\n",[32,1622,1623,1624,1627,1628,1631],{},"Now, I can start my project with the following approaches (referencing Properties\u002FlaunchSettings.json)  Regardless of how the project is started, we are taking advantage of vue dev server and the hot module reloading feature (i.e. the ability to modify html, js, vue code and the page will auto re-load)     * Visual Studio F5 (debug-run) (",[394,1625,1626],{},"selecting"," the application name) ",[305,1629],{"href":1630},"http:\u002F\u002Flocalhost:8081",[305,1632,1630],{"href":1630,"rel":1633},[784],[32,1635,1636],{},"This approach starts the project with the c# debugger attached.",[36,1638,1640],{"className":247,"code":1639,"language":249,"meta":11,"style":11},"\"aspnetcorevueappGui \": {               \n        \"commandName \":  \"Project \",               \n        \"launchBrowser \": true,               \n        \"environmentVariables \": {                 \n            \"ASPNETCORE_ENVIRONMENT \":  \"Development \"              \n        },               \n        \"applicationUrl \":  \"\u003Ca href=\"https:\u002F\u002Flocalhost:5001;http:\u002F\u002Flocalhost:5000 \"\">https:\u002F\u002Flocalhost:5001;http:\u002F\u002Flocalhost:5000 \"\u003C\u002Fa>          \n}\n",[42,1641,1642,1647,1652,1657,1662,1667,1672,1677],{"__ignoreMap":11},[45,1643,1644],{"class":47,"line":48},[45,1645,1646],{},"\"aspnetcorevueappGui \": {               \n",[45,1648,1649],{"class":47,"line":12},[45,1650,1651],{},"        \"commandName \":  \"Project \",               \n",[45,1653,1654],{"class":47,"line":60},[45,1655,1656],{},"        \"launchBrowser \": true,               \n",[45,1658,1659],{"class":47,"line":66},[45,1660,1661],{},"        \"environmentVariables \": {                 \n",[45,1663,1664],{"class":47,"line":72},[45,1665,1666],{},"            \"ASPNETCORE_ENVIRONMENT \":  \"Development \"              \n",[45,1668,1669],{"class":47,"line":112},[45,1670,1671],{},"        },               \n",[45,1673,1674],{"class":47,"line":133},[45,1675,1676],{},"        \"applicationUrl \":  \"\u003Ca href=\"https:\u002F\u002Flocalhost:5001;http:\u002F\u002Flocalhost:5000 \"\">https:\u002F\u002Flocalhost:5001;http:\u002F\u002Flocalhost:5000 \"\u003C\u002Fa>          \n",[45,1678,1679],{"class":47,"line":139},[45,1680,1129],{},[32,1682,1683,1684,1688,1691,1693],{},"*Visual Studio F5 (debug-run) (selecting IIS Express, browser by default navigates to ",[305,1685],{"title":1686,"href":1687},"http:\u002F\u002Flocalhost:50557\u002F","http:\u002F\u002Flocalhost:50557",[305,1689,1687],{"href":1687,"rel":1690},[784],[321,1692],{},"\nThis approach starts the project with the c# debugger attached.   ",[1293,1695,1696],{},[32,1697,1698,1699,1701,1702,1704,1705,1707,1708,1710,1711,1715,1716,1718,1719,1721,1722,1724],{},"\"iisSettings\": {",[321,1700],{},"\n\"windowsAuthentication\": false,",[321,1703],{},"\n\"anonymousAuthentication\": true,",[321,1706],{},"\n\"iisExpress\": {",[321,1709],{},"\n\"applicationUrl\":  \"\u003Ca href=\"",[305,1712,1714],{"rel":1713},[784],"http:\u002F\u002Flocalhost:50557\"\">http:\u002F\u002Flocalhost:50557"," \",",[321,1717],{},"\n\"sslPort \": 0",[321,1720],{},"\n}",[321,1723],{},"\n} ",[32,1726,1727,1728,1731,1734],{},"*npm run serve from a command prompt\u002Fterminal window and opening browser to ",[305,1729],{"href":1730},"http:\u002F\u002Flocalhost:8080",[305,1732,1730],{"href":1730,"rel":1733},[784],"  The c# debugger is not attached, however I will show how to attach to the dotnet.exe process below.  The port used is defined within Startup.cs spa.UseVueCli(npmScript:  \"serve \", port: 8080);   ",[1293,1736,1737,1738,1231],{},"   ",[305,1739,1741],{"href":1740},"\u002Farticles\u002Fimages\u002Fimage_636789550424336824.png",[309,1742],{"title":312,"style":1334,"border":316,"alt":312,"src":1743,"width":1305,"height":1744},"\u002Farticles\u002Fimages\u002Fimage_thumb_636789550425217823.png",98,[305,1746],{"href":1747},"http:\u002F\u002Flocalhost:8080\u002F",[305,1749,1747],{"href":1747,"rel":1750},[784],[32,1752,1753,1754,1756,1763,1764],{},"The c# debugger is not attached, however I will show how to attach to the dotnet.exe process below.  The port used is defined within Startup.cs spa.UseVueCli(npmScript:  \"serve \", port: 8080);",[321,1755],{},[305,1757,1759],{"href":1758},"\u002Farticles\u002Fimages\u002Fimage_636789550425931758.png",[309,1760],{"title":312,"style":1334,"border":316,"alt":312,"src":1761,"width":1305,"height":1762},"\u002Farticles\u002Fimages\u002Fimage_thumb_636789550426691621.png",45,"        ",[305,1765,1767],{"href":1766},"\u002Farticles\u002Fimages\u002Fimage_636789550427600206.png",[309,1768],{"title":312,"style":1334,"border":316,"alt":312,"src":1769,"width":1305,"height":1770},"\u002Farticles\u002Fimages\u002Fimage_thumb_636789550428370970.png",168,[32,1772,1773],{},"Attaching from within Visual Studio to the dotnet.exe process Debug – Attach to Process  ",[1293,1775,1737,1776,1782,1783,1231],{},[305,1777,1779],{"href":1778},"\u002Farticles\u002Fimages\u002Fimage_636789550429079347.png",[309,1780],{"title":312,"style":1334,"border":316,"alt":312,"src":1781,"width":1304,"height":1305},"\u002Farticles\u002Fimages\u002Fimage_thumb_636789550430063451.png","    ",[305,1784,1786],{"href":1785},"\u002Farticles\u002Fimages\u002Fimage_636789550431090218.png",[309,1787],{"title":312,"style":1334,"border":316,"alt":312,"src":1788,"width":1305,"height":1313},"\u002Farticles\u002Fimages\u002Fimage_thumb_636789550431817517.png",[32,1790,1791],{},"So there are a few ways of starting your web application and debugging.",[32,1793,1794,1795,1797,1798,1800],{},"If you use one of the F5 approaches (above) the debugger is automatically attached, and you can step through your code as you browse\nthrough the application.  If you use F5 you can stop debugging easily by just stopping within Visual Studio the debugger.",[321,1796],{},"\nIf you start the application from a terminal\u002Fcommand prompt window the .NET debugger is not attached however you can attach to the dotnet.exe process when you are interested in stepping into your c# .net code.",[321,1799],{},"\nPersonally, I never use F5 and rely on attaching the process when I want to narrow my debugging experience manually.",[32,1802,1803],{},"I code this way, as I can modify c#, build the project then simply just refresh my open browser to start using the updated dlls from the project.  Once the vue app is running, hot module loading is up and running.  Changes to html and js files within the ClientApp directory are automatically loaded when the Vue CLI recognizes a file change.  This is known as HMR (hot module reloading).  All new js frameworks have an implementation of this.  It is part of the new modern js framework world now.  The root file for the web application is public\u002Findex.html.",[278,1805,476],{},{"title":11,"searchDepth":12,"depth":12,"links":1807},[],"2018-11-27T22:37:23.276Z",{},"\u002Farticles\u002Fstarting-a-vue-app-wvisual-studio-aspnet-core-2",{"title":1544,"description":1549},"articles\u002Fstarting-a-vue-app-wvisual-studio-aspnet-core-2",[350,18],"vqGHUOh8tLLRV4bB39lZjIFEZF5X69F042wi9PFYnnI",{"id":1816,"title":1817,"author":28,"body":1818,"createdAt":2227,"description":1822,"extension":15,"img":1831,"meta":2228,"navigation":19,"path":2229,"seo":2230,"stem":2231,"tags":2232,"updatedAt":2227,"__hash__":2233},"articles\u002Farticles\u002Fgetting-started-vuejs-wvisual-studio-aspnet-core-1.md","Getting Started Vue.js w\u002FVisual Studio ASP.NET Core 1",{"type":8,"value":1819,"toc":2225},[1820,1823,1842,1845,1856,1871,1880,1883,1892,1925,1927,1941,1953,1963,1985,2008,2035,2038,2044,2065,2093,2161,2166,2178],[32,1821,1822],{},"So starting this off, looking for a Vue.js SPA template within Visual Studio…nope not available.\nUsing command line dotnet new –l you can see it is not within the template package from Microsoft.",[32,1824,1825,1834,1835],{},[305,1826,1828],{"href":1827},"\u002Farticles\u002Fimages\u002Fimage_636783176934907896.png",[309,1829],{"title":312,"style":1830,"border":316,"alt":312,"src":1831,"width":1832,"height":1833},"display: inline; background-image: none;","\u002Farticles\u002Fimages\u002Fimage_thumb_636783176935948243.png",308,246,"     ",[305,1836,1838],{"href":1837},"\u002Farticles\u002Fimages\u002Fimage_636783176936835671.png",[309,1839],{"title":312,"style":1830,"border":316,"alt":312,"src":1840,"width":1305,"height":1841},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176937616708.png",195,[32,1843,1844],{},"Second attempt, is to get the latest template solutions from Microsoft using the following command from a dos prompt.",[32,1846,1847,1848,1852,1855],{},"dotnet new --install ",[305,1849,1851],{"href":1850},"https:\u002F\u002Fwww.nuget.org\u002Fpackages\u002FMicrosoft.AspNetCore.SpaTemplates\u002F","microsoft.aspnetcore.spatemplates",[394,1853,1854],{},"Unfortunately",", the Vue templates are not available within this package (unlike React and Angular templates).",[32,1857,1858,1862,1863,1867,1868,1870],{},[1859,1860,1861],"u",{},"Building our own Vue Template","  I am going to build one up using existing templates from Microsoft and Visual Studio with the new\n",[305,1864,1866],{"href":1865},"https:\u002F\u002Fcli.vuejs.org\u002F","Vue CLI 3"," templating system. Starting off install the vue cli globally on your pc.",[321,1869],{},"\nnpm list –g --depth 0 (to list all globally install packages, depth argument says to list only the top packages not the dependencies)",[32,1872,1873],{},[305,1874,1876],{"href":1875},"\u002Farticles\u002Fimages\u002Fimage_636783176938295748.png",[309,1877],{"title":312,"style":1334,"border":316,"alt":312,"src":1878,"width":1305,"height":1879},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176939127447.png",106,[32,1881,1882],{},"I have already installed vue cli however doing it again you can see vue was updated from 3.0.1 to 3.1.1    npm install –g @vue\u002Fcli",[32,1884,1885],{},[305,1886,1888],{"href":1887},"\u002Farticles\u002Fimages\u002Fimage_636783176939865053.png",[309,1889],{"title":312,"style":1334,"border":316,"alt":312,"src":1890,"width":1305,"height":1891},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176940599977.png",125,[32,1893,1894,1895,1903,1904,1912,1913,1920,1922],{},"Vue CLI sets up a project with features: hot module replacement, tree-shaking, code-splitting, webpack 4 etc. node –v will display the version of node installed, likewise vue --version gives us the vue.js installed. With vue 3 cli we can use the CLI to create a project or a GUI to set it up.  Using the CLI first, we will create a asp.net core solution based on the existing react template.  dotnet new react –o aspnet-core-vue-app (this is the same as File-New Project within VS.NET and choosing the react template)  ",[305,1896,1898],{"href":1897},"\u002Farticles\u002Fimages\u002Fimage_636783176941282020.png",[309,1899],{"title":312,"style":1830,"border":316,"alt":312,"src":1900,"width":1901,"height":1902},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176942157272.png",288,81,"  Opening the csproj with vs.net (Open Project), and building the project to restore nuget packages, and restoring npm packages (taking several minutes)    ",[305,1905,1907],{"href":1906},"\u002Farticles\u002Fimages\u002Fimage_636783176942942110.png",[309,1908],{"title":312,"style":1830,"border":316,"alt":312,"src":1909,"width":1910,"height":1911},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176943756200.png",197,187,"  Make the following changes within Startup.cs    configuration.RootPath = 'ClientApp\u002Fbuild'; => configuration.RootPath = 'ClientApp\u002Fdist';     app.UseHttpsRedirection(); => \u002F\u002F app.UseHttpsRedirection(); comment out (we do not want to deal with https certificates at this moment)  Add nuget package VueClieMiddleware  ",[305,1914,1916],{"href":1915},"\u002Farticles\u002Fimages\u002Fimage_636783176944675747.png",[309,1917],{"title":312,"style":1334,"border":316,"alt":312,"src":1918,"width":1305,"height":1919},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176945464707.png",41,[321,1921],{},[305,1923],{"href":1924},"\u002Farticles\u002Fimages\u002Fimage_636783176946236903.png",[305,1926],{"href":1924},[32,1928,1929,1935,1937,1938,1940],{},[305,1930,1931],{"href":1924},[309,1932],{"title":312,"style":1334,"border":316,"alt":312,"src":1933,"width":1934,"height":1305},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176947064497.png",241,[321,1936],{},"\n\u002F\u002F spa.UseReactDevelopmentServer(npmScript: 'start'); comment out react development server and reference vue",[321,1939],{},"\nspa.UseVueCli(npmScript: 'serve', port: 8080);",[32,1942,1943,1944,1946,1947,1949,1950,1952],{},"Remove all the contents of the \u002FClientApp foler and create a new project using Vue CLI and returning to command prompt in a new directory",[321,1945],{},"\nmd vue",[321,1948],{},"\ncd vue",[321,1951],{},"\nvue create client-app",[32,1954,1955],{},[305,1956,1958],{"href":1957},"\u002Farticles\u002Fimages\u002Fimage_636783176947910505.png",[309,1959],{"title":312,"style":1830,"border":316,"alt":312,"src":1960,"width":1961,"height":1962},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176948670926.png",388,116,[32,1964,1965,1966,1968,1976,1978],{},"selecting with mouse default (babel, eslint)",[321,1967],{},[305,1969,1971],{"href":1970},"\u002Farticles\u002Fimages\u002Fimage_636783176949582507.png",[309,1972],{"title":312,"style":1830,"border":316,"alt":312,"src":1973,"width":1974,"height":1975},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176950311914.png",390,92,[321,1977],{},[305,1979,1981],{"href":1980},"\u002Farticles\u002Fimages\u002Fimage_636783176951069191.png",[309,1982],{"title":312,"style":1830,"border":316,"alt":312,"src":1983,"width":1984,"height":1305},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176951855897.png",397,[32,1986,1987,1988,1995,2003,2004,2007],{},"Moving all the Vue CLI code now to the VS.NET folder ClientApp. I am using Visual Studio in this tutorial (not vscode).  ",[305,1989,1991],{"href":1990},"\u002Farticles\u002Fimages\u002Fimage_636783176952644959.png",[309,1992],{"title":312,"style":1334,"border":316,"alt":312,"src":1993,"width":1305,"height":1994},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176953456238.png",104,[305,1996,1998],{"href":1997},"\u002Farticles\u002Fimages\u002Fimage_636783176954088989.png",[309,1999],{"title":312,"style":1830,"border":316,"alt":312,"src":2000,"width":2001,"height":2002},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176954863643.png",110,72,"  ",[1859,2005,2006],{},"3 ways to run this project","  1. Pressing F5 the application runs and to test the hot module reload feature, modify the Welcome message within App.vue while in Debug Mode (F5). You will notice the page reloads showing the change immediately. This is powerful.",[32,2009,2010,2011,2013,2014,2016,2017,2019,2020,2023,500,2026,2028,2029,2031,2032],{},"2 If however I try to run the project via dotnet run I am getting the following error:",[321,2012],{},"\nSystem.InvalidOperationException\nHResult=0x80131509",[321,2015],{},"\nMessage=Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found.",[321,2018],{},"\nTo generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.         For more information on configuring HTTPS see ",[305,2021],{"href":2022},"https:\u002F\u002Fgo.microsoft.com\u002Ffwlink\u002F?linkid=848054",[305,2024,2022],{"href":2022,"rel":2025},[784],[321,2027],{},"\nSource=Microsoft.AspNetCore.Server.Kestrel.Core",[321,2030],{},"\nStackTrace:………….info: Microsoft.AspNetCore.SpaServices",[45,2033,2034],{},"0",[32,2036,2037],{},"client-app@0.1.0 serve C:\\Temp\\vue\\aspnet-core-vue-app\\aspnet-core-vue-app\\ClientApp",[32,2039,2040,2041,2043],{},"vue-cli-service serve '--port' '8080'  INFO Starting development server...    The error message told me to run dotnet dev-certs https --clean",[321,2042],{},"\nI tried but ended up with this error message",[32,2045,2046,2047,2049,2050,2052,2053,2055,2062,2064],{},"Cleaning HTTPS development certificates from the machine. A prompt might get displayed to confirm the removal of some of the certificates.",[321,2048],{},"\nThere was an error trying to clean HTTPS development certificates on this machine.",[321,2051],{},"\nSequence contains no matching element",[321,2054],{},[305,2056,2058],{"href":2057},"\u002Farticles\u002Fimages\u002Fimage_636783176955551263.png",[309,2059],{"title":312,"style":1334,"border":316,"alt":312,"src":2060,"width":1305,"height":2061},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176956233921.png",27,[321,2063],{},"\nI was able to eventually resolve this issue (later) by opening “Manage user certificates”, removing any certificates with friendly names like “ASP.NET Core HTTPS development certificate”. Apparently there was a corruption in my local certificates and removing all resolved it.",[32,2066,2067,2074,2075,2077,2084,2086,2087,2090,1003],{},[305,2068,2070],{"href":2069},"\u002Farticles\u002Fimages\u002Fimage_636783176956890292.png",[309,2071],{"title":312,"style":1830,"border":316,"alt":312,"src":2072,"width":2073,"height":1305},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176957562139.png",243,"  I did this under Certificates Current User – Personal > Certificates (sort by friendly name, select all and remove)  Trusted Root",[321,2076],{},[305,2078,2080],{"href":2079},"\u002Farticles\u002Fimages\u002Fimage_636783176958629353.png",[309,2081],{"title":312,"style":1334,"border":316,"alt":312,"src":2082,"width":1305,"height":2083},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176959335403.png",37,[321,2085],{},"\nOnce this was complete I re-ran the dotnet dev-certs https --trust per the error message, I was then prompted with ‘A confirmation prompt will be displayed if the certificate was not previously trusted. Click yes on the prompt to trust the certification’.. (Reference: ",[305,2088],{"title":2089,"href":2089},"https:\u002F\u002Fgithub.com\u002Faspnet\u002FAspNetCore\u002Fissues\u002F3421",[305,2091,2089],{"href":2089,"rel":2092},[784],[32,2094,2095,2096,2098,2101,2102,2105,2106,2113,2114,2003,2121,2003,2128,1834,2135,2142,2143,2145,2146,2148,2149,2151,2154,2155,2157,2158,2160],{},"3 With a command prompt, cd to the ClientApp directory and npm run serve (after you can browse to the site via ",[305,2097],{"href":1730},[305,2099,1730],{"href":1730,"rel":2100},[784]," as the on screen instructions provide)  ",[394,2103,2104],{},"Let’s do this again",", but instead of creating the vue app via the vue cli this time I will use the vue ui to build the vue app. Create another React application using the template within Visual Studio. Make the same modifications as above to the Startup.cs. Using vue ui command line and the browser based wizard create another vue app named ClientApp. When complete copy it to your Visual Studio project on top of the existing ClientApp folder.  ",[305,2107,2109],{"href":2108},"\u002Farticles\u002Fimages\u002Fimage_636783176960052361.png",[309,2110],{"title":312,"style":1334,"border":316,"alt":312,"src":2111,"width":1305,"height":2112},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176960663681.png",29,"  A browser opens with the Vue GUI options  ",[305,2115,2117],{"href":2116},"\u002Farticles\u002Fimages\u002Fimage_636783176961647957.png",[309,2118],{"title":312,"style":1334,"border":316,"alt":312,"src":2119,"width":1305,"height":2120},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176962446700.png",97,[305,2122,2124],{"href":2123},"\u002Farticles\u002Fimages\u002Fimage_636783176963253878.png",[309,2125],{"title":312,"style":1334,"border":316,"alt":312,"src":2126,"width":1305,"height":2127},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176963995444.png",36,[305,2129,2131],{"href":2130},"\u002Farticles\u002Fimages\u002Fimage_636783176964694200.png",[309,2132],{"title":312,"style":1334,"border":316,"alt":312,"src":2133,"width":1305,"height":2134},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176965536783.png",94,[305,2136,2138],{"href":2137},"\u002Farticles\u002Fimages\u002Fimage_636783176966230883.png",[309,2139],{"title":312,"style":1334,"border":316,"alt":312,"src":2140,"width":1305,"height":2141},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176966867718.png",111,"  A vue app is created on the file system, which will be copied again to our Visual Studio project (on top of the ClientApp directory) that was the original React application. Build the project…. ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========  1. Pressing F5 to run the application, you can see within the Output – Debug window the operations…  Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager:Information: User profile is available. Using 'C:\\Users\\dyardy\\AppData\\Local\\ASP.NET\\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.",[321,2144],{},"\nMicrosoft.AspNetCore.SpaServices:Information: Starting server on port 8080...",[321,2147],{},"\nMicrosoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP\u002F1.1 DEBUG ",[305,2150],{"href":1686},[305,2152,1686],{"href":1686,"rel":2153},[784]," 0",[321,2156],{},"\nMicrosoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 32.0777ms 200",[321,2159],{},"\nMicrosoft.AspNetCore.SpaServices:Information: > ClientApp@0.1.0 serve C:\\Temp\\vue\\aspnetcorevueappGui\\aspnetcorevueappGui\\aspnetcorevueappGui\\ClientApp",[1293,2162,2163],{},[32,2164,2165],{},"vue-cli-service serve '--port' '8080'",[32,2167,2168,2169,2171,2172,2174,2175,2177],{},"INFO Starting development server...",[321,2170],{},"\nMicrosoft.AspNetCore.SpaServices:Information: DONE Compiled successfully in 19505ms15:42:01",[321,2173],{},"\nMicrosoft.AspNetCore.SpaServices:Information:",[321,2176],{},"\nApp running at:",[366,2179,2180,2188],{},[369,2181,2182,2183,2185],{},"Local: ",[305,2184],{"href":1747},[305,2186,1747],{"href":1747,"rel":2187},[784],[369,2189,2190,2191,2194,2197,2198,2200,2201,2208,2209,2213,2214,2217,2218,2221,2224],{},"Network: ",[305,2192],{"href":2193},"http:\u002F\u002F192.168.1.101:8080\u002F",[305,2195,2193],{"href":2193,"rel":2196},[784],"    Note that the development build is not optimized.",[321,2199],{},"\nMicrosoft.AspNetCore.SpaServices:Information: To create a production build, run npm run build.  ",[305,2202,2204],{"href":2203},"\u002Farticles\u002Fimages\u002Fimage_636783176967988657.png",[309,2205],{"title":312,"style":1830,"border":316,"alt":312,"src":2206,"width":1305,"height":2207},"\u002Farticles\u002Fimages\u002Fimage_thumb_636783176968671677.png",42,"  The browser did open navigated to ",[305,2210,2211],{"href":2211,"rel":2212},"https:\u002F\u002Flocalhost:50557\u002F",[784]," changing this to ",[305,2215,1687],{"href":1687,"rel":2216},[784]," my new project opened up.  Also ",[305,2219,1231],{"title":2220,"href":2220}," http:\u002F\u002Flocalhost:8080\u002F ",[305,2222,1747],{"href":1747,"rel":2223},[784],"  works well to.  Ok so that is the end of this initial getting started with Vue.js and ASP.NET Core. Primarily this was using templates from Visual Studio, with modification then relying on Vue.js CLI (command line and gui to build a new template based on vue.js).",{"title":11,"searchDepth":12,"depth":12,"links":2226},[],"2018-11-20T13:34:57.003Z",{},"\u002Farticles\u002Fgetting-started-vuejs-wvisual-studio-aspnet-core-1",{"title":1817,"description":1822},"articles\u002Fgetting-started-vuejs-wvisual-studio-aspnet-core-1",[18,350],"gH7c2V4YNLNu8_InM5kss4Ft-n7nbDlOeseetV4SuU4",{"id":2235,"title":2236,"author":28,"body":2237,"createdAt":2430,"description":2431,"extension":15,"img":2313,"meta":2432,"navigation":19,"path":2433,"seo":2434,"stem":2435,"tags":2436,"updatedAt":2430,"__hash__":2438},"articles\u002Farticles\u002Fxunit-what-is-it-and-why-another-unit-testing-framework.md","xUnit–what is it and why another unit testing framework",{"type":8,"value":2238,"toc":2428},[2239,2245,2275,2278,2282,2394,2397,2411,2413],[32,2240,2241,2242,2244],{},"Special thank you for Channel 9 and @skimedic for sharing his unit testing knowledge.",[321,2243],{},"\nXUnit leverage some of the new features to help developers write cleaner test, as tests should be kept clean and treated as first-class citizens.",[366,2246,2247,2250,2253,2263,2266],{},[369,2248,2249],{},"NUnit was not fully compatible with .NET Core 2 at the time",[369,2251,2252],{},"xUnit is aimed at improving test isolation and trying to codify a set of rules to establish a testing standard.",[369,2254,2255,2256,926,2259,2262],{},"xUnit ",[45,2257,2258],{},"Fact",[45,2260,2261],{},"Theory"," attributes are extensible, so you can implement your own testing functionality.xUnit doesn’t use Test Lists and .vsmdi files to keep track of your tests.",[369,2264,2265],{},"Microsoft is using xUnit internally, one of its creators is from Microsoft. xUnit was also created by one of the original authors of NUnit.",[369,2267,2268,2269,2272],{},"Side-by-side Performance Comparison of testing frameworks can be found here ",[305,2270],{"title":2271,"href":2271},"https:\u002F\u002Fblogs.msdn.microsoft.com\u002Fvisualstudio\u002F2017\u002F11\u002F16\u002Ftest-experience-improvements\u002F",[305,2273,2271],{"href":2271,"rel":2274},[784],[32,2276,2277],{},"Where to get it and how to add it to your projects (2 ways)",[2279,2280,2281],"ol",{},"  \n* Use Nuget to add xunit as well as the runner  \n* Add New Project – .NET Core xUnit Test Project  \n",[366,2283,2284,2287,2293,2296,2301,2304,2316,2319,2322,2334,2337,2340,2343,2350,2353,2364,2367,2377,2380,2383],{},[369,2285,2286],{},"It does work with live unit testing",[369,2288,2289,2290,2292],{},"Add ",[45,2291,2258],{}," attribute on a method to mark it as a test",[369,2294,2295],{},"Use Theory and InlineData as mechanism to pass data into the test",[369,2297,2298,2300],{},[45,2299,2261],{}," attribute to mark a method as a test and setup incoming parameters (2 approaches InlineData and MemberData)",[369,2302,2303],{},"[InlineData(1,2,3)",[369,2305,2306,2307],{},"approach to pass data into the test method (add additional InlineData attributes for multiple runs of same test)\n",[305,2308,2310],{"href":2309},"\u002Farticles\u002Fimages\u002FSNAGHTML2e5cfd1e_636767597902517481.png",[309,2311],{"style":311,"title":2312,"src":2313,"alt":2312,"width":2314,"height":2315,"border":316},"SNAGHTML2e5cfd1e","\u002Farticles\u002Fimages\u002FSNAGHTML2e5cfd1e_thumb_636767597903473559.png",487,209,[369,2317,2318],{},"MemberData(nameof(IEnumerable\u003Cobject>",[369,2320,2321],{},"In the example below we are using a method to return data to be used (however this method could also read data from other files such as text or excel to be returned)",[369,2323,2324,2325],{},"approach to pass data into the test method\n",[305,2326,2328],{"href":2327},"\u002Farticles\u002Fimages\u002FSNAGHTML2e5bc0f5_636767597904435811.png",[309,2329],{"style":311,"title":2330,"src":2331,"alt":2330,"width":2332,"height":2333,"border":316},"SNAGHTML2e5bc0f5","\u002Farticles\u002Fimages\u002FSNAGHTML2e5bc0f5_thumb_636767597905425086.png",484,226,[369,2335,2336],{},"xUnit runs it’s tests in parallel to take advantage of today’s processors",[369,2338,2339],{},"tests within one class are run serial",[369,2341,2342],{},"tests in multiple classes are run parallel",[369,2344,2345,2346,2349],{},"can be disabled by creating a test collection (add attribute ",[45,2347,2348],{},"Collection({name})",", and all within the same collection will be run serial",[369,2351,2352],{},"in order to test that an exception is thrown",[369,2354,2355,2356],{},"Assert.Throws\u003CInvalidOperationException>(() => ThrowAnError());\n",[305,2357,2359],{"href":2358},"\u002Farticles\u002Fimages\u002Fimage_636767597907208471.png",[309,2360],{"style":311,"title":312,"src":2361,"alt":312,"width":2362,"height":2363,"border":316},"\u002Farticles\u002Fimages\u002Fimage_thumb_636767597908147368.png",452,301,[369,2365,2366],{},"Setup\u002FTeardown",[369,2368,2369,2370,926,2373,2376],{},"There are no ",[45,2371,2372],{},"Setup",[45,2374,2375],{},"Teardown"," attributes, this is done using the test class’ constructor and an IDisposable. This encourages developers to write cleaner tests.",[369,2378,2379],{},"use constructor in place of Setup attributes to prepare tests",[369,2381,2382],{},"now use IDisposable to replace teardown i.e. public class ATestClass : IDisposable\npublic void Dispose() {\n   \u002F\u002Fsomething here to clean up\n}",[369,2384,2385,2386],{},"for input\u002Foutput there exists ITestOutputHelper as shown below to output log\n",[305,2387,2389],{"href":2388},"\u002Farticles\u002Fimages\u002Fimage_636767597909423747.png",[309,2390],{"style":311,"title":312,"src":2391,"alt":312,"width":2392,"height":2393,"border":316},"\u002Farticles\u002Fimages\u002Fimage_thumb_636767597910292790.png",447,240,[32,2395,2396],{},"Notes",[366,2398,2399,2402],{},[369,2400,2401],{},"Works in .net core and .net framework",[369,2403,2404,2405,2408],{},"TODO: Read up on Live Unit Testing ",[305,2406],{"title":2407,"href":2407},"https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fvisualstudio\u002Ftest\u002Flive-unit-testing?view=vs-2017",[305,2409,2407],{"href":2407,"rel":2410},[784],[32,2412,1224],{},[1293,2414,1295,2415,1428,2418,2421,2422,1428,2425],{},[305,2416,2417],{"title":2417,"href":2417},"https:\u002F\u002Fxunit.github.io\u002Fdocs\u002Fwhy-did-we-build-xunit-1.0.html",[305,2419,2420],{"title":2420,"href":2420},"https:\u002F\u002Fdev.to\u002Fhatsrumandcode\u002Fnet-core-2-why-xunit-and-not-nunit-or-mstest--aei","   \n",[305,2423,2424],{"title":2424,"href":2424},"https:\u002F\u002Fchannel9.msdn.com\u002FShows\u002FVisual-Studio-Toolbox\u002FUnit-Testing-xUnit",[305,2426,2427],{"title":2427,"href":2427},"https:\u002F\u002Fxunit.github.io\u002F",{"title":11,"searchDepth":12,"depth":12,"links":2429},[],"2018-11-02T12:49:51.111Z","Primarily XUnit leverages some new features to help developers write cleaner test, as tests should be kept clean and treated as first-class citizens.",{},"\u002Farticles\u002Fxunit-what-is-it-and-why-another-unit-testing-framework",{"title":2236,"description":2431},"articles\u002Fxunit-what-is-it-and-why-another-unit-testing-framework",[18,2437],"testing","Xa57WSBlnynbn4MUPddzdtkn0rAmRbojbJ2tqgZD33w",{"id":2440,"title":2441,"author":28,"body":2442,"createdAt":2613,"description":2614,"extension":15,"img":2615,"meta":2616,"navigation":19,"path":2617,"seo":2618,"stem":2619,"tags":2620,"updatedAt":2613,"__hash__":2621},"articles\u002Farticles\u002Fnet-standard-vs-net-core.md",".NET Standard vs. .NET Core",{"type":8,"value":2443,"toc":2611},[2444,2447,2450,2453,2456,2475,2537,2594],[32,2445,2446],{},"In Visual Studio, there are at least 3 different types of class library you can create:",[32,2448,2449],{},"*Class Library (.NET Framework)\n*Class Library (.NET Standard)\n*Class Library (.NET Core)",[32,2451,2452],{},"Use a .NET Standard library when you want to increase the number of apps that will be compatible with your library, and you are okay with\na decrease in the .NET API surface area your library can access.",[32,2454,2455],{},"Use a .NET Core library when you want to increase the .NET API surface area your library can access, and you are okay with allowing only\n.NET Core apps to be compatible with your library.",[32,2457,2458,2459,2462,2463,2466,2467,2470,2471,2474],{},"Difference:\nCompatibility: Libraries that target .NET Standard will run on any .NET Standard compliant runtime, such as .NET Core, .NET Framework, Mono\u002FXamarin. On the other hand, libraries that target .NET Core can only run on the .NET Core runtime.\nAPI Surface Area: .NET Standard libraries come with everything in ",[42,2460,2461],{},"NETStandard.Library"," whereas .NET Core libraries come with everything in ",[42,2464,2465],{},"Microsoft.NETCore.App",". The latter includes approximately 20 additional libraries, some of which we can add manually to our .NET Standard library (such as ",[42,2468,2469],{},"System.Threading.Thread",") and some of which are not compatible with the .NET Standard (such as ",[42,2472,2473],{},"Microsoft.NETCore.CoreCLR",").\nAlso, .NET Core libraries specify a runtime and come with an application model. That's important, for instance, to make unit test class libraries runnable.\nIgnoring libraries for a moment, the reason that .NET Standard exists is for portability; it defines a set of APIs that .NET platforms agree to implement. Any platform that implements a .NET Standard is compatible with libraries that target that .NET Standard. One of those compatible platforms is .NET Core.\nComing back to libraries, the .NET Standard library templates exist to run on multiple runtimes (at the expense of API surface area). Obversely, the .NET Core library templates exist to access more API surface area (at the expense of compatibility) and to specify a platform against which to build an executable.\nSaid another way…",[32,2476,2477,2478,2481,2482,2485,2486,2489,2490,926,2493,2496,2497,2500,2503,2504,926,2506,838,2508,2510,2511,926,2513,2515,2516,2519,2520,2522,2523,2526,2527,2530,2531,2533,2534,500],{},"A ",[394,2479,2480],{},".Net Core Class Library"," is built upon the ",[394,2483,2484],{},".Net Standard",". If you want to implement a library that is portable to the ",[394,2487,2488],{},".Net Framework",", .",[394,2491,2492],{},"Net Core",[394,2494,2495],{},"Xamarin",", choose a ",[394,2498,2499],{},".Net Standard Library",[394,2501,2502],{},".Net Core will ultimately implement .Net Standard 2"," (as will ",[394,2505,2495],{},[394,2507,2488],{},[394,2509,1210],{},", ",[394,2512,2495],{},[394,2514,2488],{}," can, therefore, be identified as ",[394,2517,2518],{},"flavours"," of ",[394,2521,2484],{},"\nTo future-proof your applications for code sharing and reuse , you would rather implement .Net Standard libraries.\nMicrosoft also recommends that you use ",[394,2524,2525],{},".NET Standard"," instead of ",[394,2528,2529],{},"Portable Class Libraries",".\nTo quote MSDN as an authoritative source, ",[394,2532,2484],{}," is intended to be ",[394,2535,2536],{},"One Library to Rule Them All",[32,2538,2539,2541,2542,2544,2545,2548,2549,2552,2553,2556,2557,926,2560,2563,2564,2567,2568,2489,2571,2574,2575,2577,2578,2581,2582,2584,2585,2587,2588,1231,2590,2593],{},[394,2540,2525],{}," solves the code sharing problem for .NET developers across all platforms by bringing all the APIs that you expect and love across the environments that you need: desktop applications, mobile apps & games, and cloud services:\n",[394,2543,2525],{}," is a ",[394,2546,2547],{},"set of APIs"," that ",[394,2550,2551],{},"all"," .NET platforms ",[394,2554,2555],{},"have to implement",". This ",[394,2558,2559],{},"unifies the .NET platforms",[394,2561,2562],{},"prevents future fragmentation",".\n",[394,2565,2566],{},".NET Standard 2.0"," will be implemented by ",[394,2569,2570],{},".NET Framework",[394,2572,2573],{},"NET Core",", and ",[394,2576,2495],{},". For ",[394,2579,2580],{},".NET Core",", this will add many of the existing APIs that have been requested.\n",[394,2583,2566],{}," includes a compatibility shim for ",[394,2586,2570],{}," binaries, significantly increasing the set of libraries that you can reference from your .NET Standard libraries.\n",[394,2589,2525],{},[394,2591,2592],{},"will replace Portable Class Libraries (PCLs)"," as the tooling story for building multi-platform .NET libraries.",[32,2595,2596,2597,2600,1231,2603,2605,2608],{},"References: ",[305,2598],{"title":2599,"href":2599},"https:\u002F\u002Fblogs.msdn.microsoft.com\u002Fdotnet\u002F2016\u002F09\u002F26\u002Fintroducing-net-standard\u002F",[305,2601,2599],{"href":2599,"rel":2602},[784],[321,2604],{},[305,2606],{"title":2607,"href":2607},"https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F42939454\u002Fwhat-is-the-difference-between-net-core-and-net-standard-class-library-project",[305,2609,2607],{"href":2607,"rel":2610},[784],{"title":11,"searchDepth":12,"depth":12,"links":2612},[],"2018-10-30T16:21:49.892Z","Core vs. Standard has come up a lot recently.  I wanted to re-emphasize the differences here for my own purposes using references mentioned below.  Really important to know and understand.","\u002Farticles\u002Fimages\u002Fopen-live-writer-keep-nuget-packages-out-of-tfs-source-co_8714-tfs3_thumb.png",{},"\u002Farticles\u002Fnet-standard-vs-net-core",{"title":2441,"description":2614},"articles\u002Fnet-standard-vs-net-core",[18],"kx8ta9AYIZhNb3zhlW22x73UcUBy7FRGgPUlFaQWAC0",{"id":2623,"title":2624,"author":1188,"body":2625,"createdAt":2681,"description":28,"extension":15,"img":2660,"meta":2682,"navigation":19,"path":2683,"seo":2684,"stem":2685,"tags":2686,"updatedAt":2681,"__hash__":2687},"articles\u002Farticles\u002Fnet-roslyn-compiler-platform.md",".NET ‘Roslyn’ Compiler Platform",{"type":8,"value":2626,"toc":2679},[2627,2633,2636,2639,2642,2645,2648],[32,2628,2629,2630,2632],{},"Roslyn – is a recently released .NET Compiler Platform for .NET 4.6+   There is plenty of information on the web that describes this platform and where it can be utilized.\n.NET Compiler Platform, better known by its codename \"Roslyn\", is a set of open-source compilers and code analysis APIs for C# and Visual Basic .NET languages from Microsoft.",[321,2631],{},"\nThe project notably includes self-hosting versions of the C# and VB.NET compilers – compilers written in the languages themselves.",[32,2634,2635],{},"The compilers are available via the\ntraditional command-line programs but also as APIs available natively from within .NET code. Roslyn exposes modules for syntactic (lexical) analysis of code, semantic analysis,\ndynamic compilation to CIL, and code emission.",[32,2637,2638],{},"Traditionally, compilers are black boxes -- source code goes in one end, magic happens in the middle, and object files or assemblies come out the other end. As compilers\nperform their magic, they build up deep understanding of the code they are processing, but that knowledge is unavailable to anyone but the compiler implementation wizards.\nThe information is promptly forgotten after the translated output is produced.",[32,2640,2641],{},"For decades, this world view has served us well, but it is no longer sufficient. Increasingly we rely on integrated development environment (IDE) features such as\nIntelliSense, refactoring, intelligent rename, “Find all references,” and “Go to definition” to increase our productivity. We rely on code analysis tools to improve our code\nquality and code generators to aid in application construction. As these tools get smarter, they need access to more and more of the deep code knowledge that only compilers\npossess.",[32,2643,2644],{},"This is the core mission of the .NET Compiler Platform (“Roslyn”): opening up the black boxes and allowing tools and end users to share in the wealth of information\ncompilers have about our code. Instead of being opaque source-code-in and object-code-out translators, through the .NET Compiler Platform (“Roslyn”), compilers become\nplatforms—APIs that you can use for code related tasks in your tools and applications.",[32,2646,2647],{},"The transition to compilers as platforms dramatically lowers the barrier to entry for creating code focused tools and applications. It creates many opportunities for\ninnovation in areas such as meta-programming, code generation and transformation, interactive use of the C# and VB languages, and embedding of C# and VB in domain specific\nlanguages.",[32,2649,2650,2651,2653,2654,2663,2665,2666,2668,2669,2673,2668,2675],{},"The .NET Compiler Platform (“Roslyn”) SDK Preview includes the latest drafts of new language object models for code generation, analysis, and refactoring. We hope to\ninclude drafts of API support for scripting and interactive use of C# and Visual Basic in a future preview. This document provides a conceptual overview of the .NET Compiler Platform (“Roslyn”). Further details can be found in the walkthroughs and samples included in the SDK Preview.",[321,2652],{},"\n ",[305,2655,2657],{"href":2656},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-e08dc9d5742net-roslyn-compiler-platform_7627-ros_2.jpg",[309,2658],{"style":2659,"src":2660,"border":316,"alt":2661,"title":2661,"width":2393,"height":2662},"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border: 0px;","\u002Farticles\u002Fimages\u002Fwindows-live-writer-e08dc9d5742net-roslyn-compiler-platform_7627-ros_thumb.jpg","ros",120,[321,2664],{},"\nReferences:",[321,2667],{},"\n· ",[305,2670,2672],{"href":2671},"https:\u002F\u002Fgithub.com\u002Fdotnet\u002Froslyn\u002Fwiki\u002FRoslyn%20Overview","Roslyn Overview",[321,2674],{},[305,2676,2678],{"href":2677},"http:\u002F\u002Fblogs.msdn.com\u002Fb\u002Fwebdev\u002Farchive\u002F2014\u002F05\u002F12\u002Fenabling-the-net-compiler-platform-roslyn-in-asp-net-applications.aspx","Enabling the .NET Compiler Platform (“Roslyn”) in ASP.NET applications",{"title":11,"searchDepth":12,"depth":12,"links":2680},[],"2015-10-03T07:17:58.5900000-04:00",{},"\u002Farticles\u002Fnet-roslyn-compiler-platform",{"title":2624,"description":28},"articles\u002Fnet-roslyn-compiler-platform",[18],"VzDtwy5NenSIF7bhmLWeInVGvfQG8fSCLTHSz1axGDU",{"id":2689,"title":2690,"author":1188,"body":2691,"createdAt":2813,"description":28,"extension":15,"img":2814,"meta":2815,"navigation":19,"path":2816,"seo":2817,"stem":2818,"tags":2819,"updatedAt":2813,"__hash__":2820},"articles\u002Farticles\u002Fnet-releases-versions-in-2015.md",".NET Releases & Versions in 2015",{"type":8,"value":2692,"toc":2811},[2693,2715,2750,2765,2768,2776,2787,2792,2800],[32,2694,2695,2696,2698,2699,2702,2703,2706,2707,2709,2711,2714],{},"In 2015 we will have new releases of .NET Framework, ASP.NET versions, Web Forms, MVC versions.  That is quite a bit to keep track of.  This should make it a little easier.  I am surprised that Microsoft has not made it more clear as to what is included in which version.  They recently starting calling this bundle .NET 2015 and as a bundle includes a number of sub-products.",[321,2697],{},"\nSo starting with the ",[394,2700,2701],{},".NET 2015 ","Bundle….it includes ",[394,2704,2705],{},".NET 4.6"," AND ",[394,2708,2580],{},[321,2710],{},[394,2712,2713],{},".NET 4.6 and .NET Core ","includes..(.NET 4.6 is included with Visual Studio 2015)",[366,2716,2717,2724,2727,2732,2735,2738,2741,2744,2747],{},[369,2718,2719,2723],{},[305,2720,2722],{"href":2721},"http:\u002F\u002Fblogs.msdn.com\u002Fb\u002Fwebdev\u002Farchive\u002F2015\u002F02\u002F09\u002Fasp-net-mvc-5-2-3-web-pages-3-2-3-and-web-api-5-2-3-release.aspx","ASP.NET 4.6","  is an umbrella term used to describe updates to existing frameworks such as ASP.NET Web Forms\u002FMVC 5\u002FWeb Api 2.",[369,2725,2726],{},"ASP.NET Web Forms 46",[369,2728,2729,2730],{},"ASP.NET MVC 5.2.3 – updates to MVC 5 found ",[305,2731,763],{"href":2721},[369,2733,2734],{},"ASP.NET Web Pages 3.2.3",[369,2736,2737],{},"ASP.NET Web API 5.2.3",[369,2739,2740],{},"ASP.NET SignalR 2.1.2",[369,2742,2743],{},"ASP.NET 5.0 Beta 5 (vNext)  – a .NET platform for build cloud-based apps and can be hosted on IIS or self-hosted in a custom process.  It supports running on both the .NET Framework and .NET Core so by extension supports running on Windows, Linux, OS X etc.",[369,2745,2746],{},"MVC 6.0 - MVC, Web API, and Web Pages are unified into a single framework – this is a complete rewrite of MVC engine we use today, while we still have controllers, views and models under the hood MVC 6 is an improved and rewritten engine.  Web API is now fully integrated with MVC 6",[369,2748,2749],{},"C# 6, F# 4, VB 14",[32,2751,2752,2753,2757,2759,2762,2764],{},"Note: .NET 4.6 is an in-place update to versions .NET 4, 4.5, 4.5.1, 4.5.2 > this means that after installation c:\\windows\\Microsoft.NET\\Framework(bitness)\\v4.0.30319 will be updated with the latest dlls, this is similar to how .NET 3.5 was an in-place update to .NET 2.0.  See also ",[305,2754,2756],{"href":2755},"https:\u002F\u002Fmsdn.microsoft.com\u002Fen-us\u002Flibrary\u002Fbb822049(v=vs.110).aspx",".NET Framework Versions and Dependencies",[321,2758],{},[394,2760,2761],{},"\nToday (August 2015) ",[321,2763],{},"\nSO if you are building an application today you can open Visual Studio 2015 and create new project(s) – web project – selecting .NET 4.6 and ASP.NET 4.6 templates (empty, web forms, mvc, etc.).  However, if you wanting to try out new ASP.NET 5 preview templates those are available too (i.e. choose .NET 4.6 and ASP.NET 5 (Preview) templates such as empty, web api and web application)",[32,2766,2767],{},"Also if you have not installed .NET 4.6 on the server you would choose to create a new project you could select .NET 4.5.2 and respective ASP.NET 4.5.2 web templates (empty, web forms, mvc, etc.)",[32,2769,2770,2771,2773],{},"Note here that Microsoft released Visual Studio 2015 with updates to existing frameworks as well as preview releases of ASP.NET and Entity Framework 7.  So confusing.",[321,2772],{},[394,2774,2775],{},"\nVisual Studio 2015 – Updates",[366,2777,2778,2781,2784],{},[369,2779,2780],{},"JSON Editor",[369,2782,2783],{},"HTML Editor Updates",[369,2785,2786],{},"JavaScript Editor Improvements",[32,2788,2789],{},[394,2790,2791],{},"Resources",[366,2793,2794],{},[369,2795,2796],{},[305,2797,2799],{"href":2798},"http:\u002F\u002Fblogs.msdn.com\u002Fb\u002Fdotnet\u002Fp\u002Fdotnet_sdks.aspx?source=VS2013",".NET SDKs and Downloads",[32,2801,2802],{},[305,2803,2805],{"href":2804},"\u002Farticles\u002Fimages\u002Fwindows-live-writer-f6d15fa95net-releases-versions-in-2015_11a94-version_4.png",[309,2806],{"style":2807,"src":2808,"border":316,"alt":2809,"title":2809,"width":2393,"height":2810},"background-image: none; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-width: 0px;","\u002Farticles\u002Fimageswindows-live-writer-f6d15fa95net-releases-versions-in-2015_11a94-version_thumb_1.png","version",143,{"title":11,"searchDepth":12,"depth":12,"links":2812},[],"2015-06-16T16:09:46.7300000-04:00","\u002Farticles\u002Fimages\u002Fwindows-live-writer-f6d15fa95net-releases-versions-in-2015_11a94-version_thumb_1.png",{},"\u002Farticles\u002Fnet-releases-versions-in-2015",{"title":2690,"description":28},"articles\u002Fnet-releases-versions-in-2015",[487,18],"RihqeLfTiAz21FdMOWIpdgYXNEmdlz_YWHgD_XX1Zf0",{"id":2822,"title":2823,"author":1188,"body":2824,"createdAt":3524,"description":28,"extension":15,"img":3521,"meta":3525,"navigation":19,"path":3526,"seo":3527,"stem":3528,"tags":3529,"updatedAt":3524,"__hash__":3530},"articles\u002Farticles\u002Fgenericcollection-usage-in-the-net-framework.md","Generic(Collection) Usage in the .NET Framework",{"type":8,"value":2825,"toc":3522},[2826,2832,2835,2930,3021,3156,3159,3299,3368,3371,3374,3387,3390,3488,3496,3504,3507,3510,3513],[32,2827,2828,2829,2831],{},"Generics provide a way for developers to define subroutines, functions, fields, properties as well as classes, structures, interfaces and even delegates in such a way that the parameters are not of any particular type.  In a sense the constructs are defined in a generic approach.",[321,2830],{},"\nThe .NET Framework contains the following namespaces:System.Collections, System.Collections.Generic.    The latter mimics very much the features of the former. ",[32,2833,2834],{},"System.Collections namespace (nongeneric)",[2836,2837,1295,2839,1295],"table",{"border":316,"cellSpacing":2034,"cellPadding":2034,"style":2838},"width: 515px;",[2840,2841,1295,2842,1295,2859,1295,2870,1295,2881,1295,2892,1295,2902,1295,2912,1295,2922,1295],"tbody",{},[2843,2844,1295,2845,1295,2851,1295,2855,1295],"tr",{},[2846,2847,2850],"td",{"width":2848,"vAlign":2849},152,"top","ICollection",[2846,2852,2854],{"width":2853,"vAlign":2849},224,"(size, enumeration, thread safety)",[2846,2856,2858],{"width":2857,"vAlign":2849},137,"derives from IEnumerable",[2843,2860,1295,2861,1295,2864,1295,2867,1295],{},[2846,2862,2863],{"width":2848,"vAlign":2849},"IComparer",[2846,2865,2866],{"width":2853,"vAlign":2849},"Allows two objects to be compared",[2846,2868,2869],{"width":2857,"vAlign":2849}," ",[2843,2871,1295,2872,1295,2875,1295,2878,1295],{},[2846,2873,2874],{"width":2848,"vAlign":2849},"IDictionary",[2846,2876,2877],{"width":2853,"vAlign":2849},"Collection object to represent its contents using name\u002Fvalue pairs",[2846,2879,2880],{"width":2857,"vAlign":2849},"derives from ICollection, IEnumerable",[2843,2882,1295,2883,1295,2886,1295,2889,1295],{},[2846,2884,2885],{"width":2848,"vAlign":2849},"IDictionaryEnumerator",[2846,2887,2888],{"width":2853,"vAlign":2849},"Enumerates the contents of a type supporting IDictionary",[2846,2890,2891],{"width":2857,"vAlign":2849},"derives from IEnumerator",[2843,2893,1295,2894,1295,2897,1295,2900,1295],{},[2846,2895,2896],{"width":2848,"vAlign":2849},"IEnumerable",[2846,2898,2899],{"width":2853,"vAlign":2849},"Returns IEnumerator interface for a collection",[2846,2901,2869],{"width":2857,"vAlign":2849},[2843,2903,1295,2904,1295,2907,1295,2910,1295],{},[2846,2905,2906],{"width":2848,"vAlign":2849},"IEnumerator",[2846,2908,2909],{"width":2853,"vAlign":2849},"Enables for each style iteration of items in collection",[2846,2911,2869],{"width":2857,"vAlign":2849},[2843,2913,1295,2914,1295,2917,1295,2920,1295],{},[2846,2915,2916],{"width":2848,"vAlign":2849},"IList",[2846,2918,2919],{"width":2853,"vAlign":2849},"Provides add, remove and index items in a list of objects",[2846,2921,2880],{"width":2857,"vAlign":2849},[2843,2923,1295,2924,1295,2926,1295,2928,1295],{},[2846,2925,2869],{"width":2848,"vAlign":2849},[2846,2927,2869],{"width":2853,"vAlign":2849},[2846,2929,2869],{"width":2857,"vAlign":2849},[2931,2932,1295,2934,1295],"div",{"id":2933},"codeSnippetWrapper",[2931,2935,1295,2938,1295,1295,2949,1295,1295,2956,1295,1295,2978,1295,1295,2991,1295,1295,3003,1295,1295,3015,1295],{"id":2936,"style":2937},"codeSnippet","padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;",[36,2939,2941,1231,2945,2948],{"style":2940},"margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: white;",[45,2942,2944],{"style":2943},"color: #0000ff;","Public",[45,2946,2947],{"style":2943},"Interface"," ICollection",[36,2950,2003,2952,2955],{"style":2951},"margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;",[45,2953,2954],{"style":2943},"Inherits"," IEnumerable",[36,2957,2003,2958,2961,2962,2965,2966,2969,2970,2972,2973,1231,2975,1003],{"style":2940},[45,2959,2960],{"style":2943},"Sub"," CopyTo(",[45,2963,2964],{"style":2943},"ByVal"," array ",[45,2967,2968],{"style":2943},"As"," Array, ",[45,2971,2964],{"style":2943}," index ",[45,2974,2968],{"style":2943},[45,2976,2977],{"style":2943},"Integer",[36,2979,2003,2980,1231,2983,2986,2987,1231,2989],{"style":2951},[45,2981,2982],{"style":2943},"ReadOnly",[45,2984,2985],{"style":2943},"Property"," Count() ",[45,2988,2968],{"style":2943},[45,2990,2977],{"style":2943},[36,2992,2003,2993,1231,2995,2997,2998,1231,3000],{"style":2940},[45,2994,2982],{"style":2943},[45,2996,2985],{"style":2943}," IsSynchronized() ",[45,2999,2968],{"style":2943},[45,3001,3002],{"style":2943},"Boolean",[36,3004,2003,3005,1231,3007,3009,3010,1231,3012],{"style":2951},[45,3006,2982],{"style":2943},[45,3008,2985],{"style":2943}," SyncRoot() ",[45,3011,2968],{"style":2943},[45,3013,3014],{"style":2943},"Object",[36,3016,3017,3020],{"style":2940},[45,3018,3019],{"style":2943},"End"," Interface",[2931,3022,1295,3023,1295],{"id":2933},[2931,3024,1295,3025,1295,1295,3032,1295,1295,3037,1295,1295,3056,1295,1295,3061,1295,1295,3078,1295,1295,3086,1295,1295,3097,1295,1295,3108,1295,1295,3119,1295,1295,3134,1295,1295,3143,1295,1295,3152,1295],{"id":2936,"style":2937},[36,3026,3027,1231,3029,3031],{"style":2940},[45,3028,2944],{"style":2943},[45,3030,2947],{"style":2943}," IDictionary",[36,3033,2003,3034,3036],{"style":2951},[45,3035,2954],{"style":2943}," ICollection, IEnumerable",[36,3038,2003,3039,3041,3042,3044,3045,1231,3047,2510,3049,3051,3052,1231,3054,1003],{"style":2940},[45,3040,2960],{"style":2943}," Add(",[45,3043,2964],{"style":2943}," key ",[45,3046,2968],{"style":2943},[45,3048,3014],{"style":2943},[45,3050,2964],{"style":2943}," value ",[45,3053,2968],{"style":2943},[45,3055,3014],{"style":2943},[36,3057,2003,3058,3060],{"style":2951},[45,3059,2960],{"style":2943}," Clear()",[36,3062,2003,3063,3066,3067,3044,3069,1231,3071,3073,3074,1231,3076],{"style":2940},[45,3064,3065],{"style":2943},"Function"," Contains(",[45,3068,2964],{"style":2943},[45,3070,2968],{"style":2943},[45,3072,3014],{"style":2943},") ",[45,3075,2968],{"style":2943},[45,3077,3002],{"style":2943},[36,3079,2003,3080,3082,3083,3085],{"style":2951},[45,3081,3065],{"style":2943}," GetEnumerator() ",[45,3084,2968],{"style":2943}," IDictionaryEnumerator",[36,3087,2003,3088,3090,3091,3044,3093,1231,3095,1003],{"style":2940},[45,3089,2960],{"style":2943}," Remove(",[45,3092,2964],{"style":2943},[45,3094,2968],{"style":2943},[45,3096,3014],{"style":2943},[36,3098,2003,3099,1231,3101,3103,3104,1231,3106],{"style":2951},[45,3100,2982],{"style":2943},[45,3102,2985],{"style":2943}," IsFixedSize() ",[45,3105,2968],{"style":2943},[45,3107,3002],{"style":2943},[36,3109,2003,3110,1231,3112,3114,3115,1231,3117],{"style":2940},[45,3111,2982],{"style":2943},[45,3113,2985],{"style":2943}," IsReadOnly() ",[45,3116,2968],{"style":2943},[45,3118,3002],{"style":2943},[36,3120,2003,3121,3123,3124,3044,3126,1231,3128,3073,3130,1231,3132],{"style":2951},[45,3122,2985],{"style":2943}," Item(",[45,3125,2964],{"style":2943},[45,3127,2968],{"style":2943},[45,3129,3014],{"style":2943},[45,3131,2968],{"style":2943},[45,3133,3014],{"style":2943},[36,3135,2003,3136,1231,3138,3140,3141,2948],{"style":2940},[45,3137,2982],{"style":2943},[45,3139,2985],{"style":2943}," Keys() ",[45,3142,2968],{"style":2943},[36,3144,2003,3145,1231,3147,3149,3150,2948],{"style":2951},[45,3146,2982],{"style":2943},[45,3148,2985],{"style":2943}," Values() ",[45,3151,2968],{"style":2943},[36,3153,3154,3020],{"style":2940},[45,3155,3019],{"style":2943},[32,3157,3158],{},"IList provides the ability to insert, remove and index items",[2931,3160,1295,3161,1295],{"id":2933},[2931,3162,1295,3163,1295,1295,3170,1295,1295,3174,1295,1295,3188,1295,1295,3192,1295,1295,3206,1295,1295,3221,1295,1295,3238,1295,1295,3248,1295,1295,3259,1295,1295,3269,1295,1295,3279,1295,1295,3293,1295],{"id":2936,"style":2937},[36,3164,3165,1231,3167,3169],{"style":2940},[45,3166,2944],{"style":2943},[45,3168,2947],{"style":2943}," IList",[36,3171,2003,3172,3036],{"style":2951},[45,3173,2954],{"style":2943},[36,3175,2003,3176,3041,3178,3051,3180,1231,3182,3073,3184,1231,3186],{"style":2940},[45,3177,3065],{"style":2943},[45,3179,2964],{"style":2943},[45,3181,2968],{"style":2943},[45,3183,3014],{"style":2943},[45,3185,2968],{"style":2943},[45,3187,2977],{"style":2943},[36,3189,2003,3190,3060],{"style":2951},[45,3191,2960],{"style":2943},[36,3193,2003,3194,3066,3196,3051,3198,1231,3200,3073,3202,1231,3204],{"style":2940},[45,3195,3065],{"style":2943},[45,3197,2964],{"style":2943},[45,3199,2968],{"style":2943},[45,3201,3014],{"style":2943},[45,3203,2968],{"style":2943},[45,3205,3002],{"style":2943},[36,3207,2003,3208,3210,3211,3051,3213,1231,3215,3073,3217,1231,3219],{"style":2951},[45,3209,3065],{"style":2943}," IndexOf(",[45,3212,2964],{"style":2943},[45,3214,2968],{"style":2943},[45,3216,3014],{"style":2943},[45,3218,2968],{"style":2943},[45,3220,2977],{"style":2943},[36,3222,2003,3223,3225,3226,2972,3228,1231,3230,2510,3232,3051,3234,1231,3236,1003],{"style":2940},[45,3224,2960],{"style":2943}," Insert(",[45,3227,2964],{"style":2943},[45,3229,2968],{"style":2943},[45,3231,2977],{"style":2943},[45,3233,2964],{"style":2943},[45,3235,2968],{"style":2943},[45,3237,3014],{"style":2943},[36,3239,2003,3240,3090,3242,3051,3244,1231,3246,1003],{"style":2951},[45,3241,2960],{"style":2943},[45,3243,2964],{"style":2943},[45,3245,2968],{"style":2943},[45,3247,3014],{"style":2943},[36,3249,2003,3250,3252,3253,2972,3255,1231,3257,1003],{"style":2940},[45,3251,2960],{"style":2943}," RemoveAt(",[45,3254,2964],{"style":2943},[45,3256,2968],{"style":2943},[45,3258,2977],{"style":2943},[36,3260,2003,3261,1231,3263,3103,3265,1231,3267],{"style":2951},[45,3262,2982],{"style":2943},[45,3264,2985],{"style":2943},[45,3266,2968],{"style":2943},[45,3268,3002],{"style":2943},[36,3270,2003,3271,1231,3273,3114,3275,1231,3277],{"style":2940},[45,3272,2982],{"style":2943},[45,3274,2985],{"style":2943},[45,3276,2968],{"style":2943},[45,3278,3002],{"style":2943},[36,3280,2003,3281,3123,3283,2972,3285,1231,3287,3073,3289,1231,3291],{"style":2951},[45,3282,2985],{"style":2943},[45,3284,2964],{"style":2943},[45,3286,2968],{"style":2943},[45,3288,2977],{"style":2943},[45,3290,2968],{"style":2943},[45,3292,3014],{"style":2943},[36,3294,3295,1231,3297],{"style":2940},[45,3296,3019],{"style":2943},[45,3298,2947],{"style":2943},[2836,3300,1295,3302,1295],{"border":316,"cellSpacing":2034,"cellPadding":2034,"style":3301},"width: 711px;",[2840,3303,1295,3304,1295,3318,1295,3329,1295,3340,1295,3350,1295,3360,1295],{},[2843,3305,1295,3306,1295,3310,1295,3314,1295],{},[2846,3307,3309],{"width":3308,"vAlign":2849},133,"ArrayList",[2846,3311,3313],{"width":3312,"vAlign":2849},414,"dynamically sized \nDim personList as New ArrayList() \npersonList.AddRange(New Person(){New Person(“dave”), New Person(“tom”)}",[2846,3315,3317],{"width":3316,"vAlign":2849},162,"IList \nICollection \nIEnumerable \nICloneable",[2843,3319,1295,3320,1295,3323,1295,3326,1295],{},[2846,3321,3322],{"width":3308,"vAlign":2849},"Hashtable",[2846,3324,3325],{"width":3312,"vAlign":2849},"collection whereby each item is represented by a numerical key",[2846,3327,3328],{"width":3316,"vAlign":2849},"IDictionary \nICollection \nIEnumerable \nICloneable",[2843,3330,1295,3331,1295,3334,1295,3337,1295],{},[2846,3332,3333],{"width":3308,"vAlign":2849},"Queue",[2846,3335,3336],{"width":3312,"vAlign":2849},"first in – first out queue with members Dequeue() (removes object at the top of queue), Enqueue() (adds object to end of queue), Peek() (returns object at the beginning of queue without removing it)",[2846,3338,3339],{"width":3316,"vAlign":2849},"ICollection \nICloneable \nIEnumerable",[2843,3341,1295,3342,1295,3345,1295,3348,1295],{},[2846,3343,3344],{"width":3308,"vAlign":2849},"SortedList",[2846,3346,3347],{"width":3312,"vAlign":2849},"similar to dictionary however items can be accessed by ordinal position",[2846,3349,3328],{"width":3316,"vAlign":2849},[2843,3351,1295,3352,1295,3355,1295,3358,1295],{},[2846,3353,3354],{"width":3308,"vAlign":2849},"Stack",[2846,3356,3357],{"width":3312,"vAlign":2849},"last in – first out queue using push, pop and peek",[2846,3359,3339],{"width":3316,"vAlign":2849},[2843,3361,1295,3362,1295,3364,1295,3366,1295],{},[2846,3363,2869],{"width":3308,"vAlign":2849},[2846,3365,2869],{"width":3312,"vAlign":2849},[2846,3367,2869],{"width":3316,"vAlign":2849},[394,3369,3370],{},"System.Collections.Generic",[32,3372,3373],{},"Boxing\u002FUnboxing is a term that is used when a value type variable is stored in a reference type structure.  This occurs with all nongeneric types as they operate of the System.Objects type.",[32,3375,3376,3377,3379,3380,3382,3383,3386],{},"For example:\nDim ar as New ArrayList()\nar.Add(123) ‘boxing occurs\nDim i as Integer = CType(ar(0), Integer) ‘unboxing occurs",[321,3378],{},"\n\u003Cp$1$2$3$4$5$6> ",[321,3381],{},"\nUsing a generic collection:\n",[394,3384,3385],{},"Dim ar as New List(Of Integer)","\nar.Add(10) ‘no boxing\nDim i as Integer = ar(0) ‘no unboxing",[32,3388,3389],{},"The following is a list of interfaces within the System.Collections.Generic namespace: ICollections(Of T), IComparer(Of T), IDictionary(Of K, V), IEnumerable(Of T), IEnumerator(Of T), and IList(Of T).  There respective classes are as follows:",[2836,3391,1295,3393,1295],{"border":316,"cellSpacing":2034,"cellPadding":2034,"style":3392},"width: 657px;",[2840,3394,1295,3395,1295,3408,1295,3418,1295,3428,1295,3438,1295,3448,1295,3458,1295,3468,1295,3478,1295],{},[2843,3396,1295,3397,1295,3401,1295,3405,1295],{},[2846,3398,3400],{"width":3399,"vAlign":2849},198,"Collection(Of T)",[2846,3402,3404],{"width":3403,"vAlign":2849},274,"generic collection",[2846,3406,2869],{"width":3407,"vAlign":2849},183,[2843,3409,1295,3410,1295,3413,1295,3416,1295],{},[2846,3411,3412],{"width":3399,"vAlign":2849},"Comparer(Of T)",[2846,3414,3415],{"width":3403,"vAlign":2849},"compares two generic objects",[2846,3417,2869],{"width":3407,"vAlign":2849},[2843,3419,1295,3420,1295,3423,1295,3426,1295],{},[2846,3421,3422],{"width":3399,"vAlign":2849},"Dictionary(Of K, V)",[2846,3424,3425],{"width":3403,"vAlign":2849},"name\u002Fvalue pairs",[2846,3427,2869],{"width":3407,"vAlign":2849},[2843,3429,1295,3430,1295,3433,1295,3436,1295],{},[2846,3431,3432],{"width":3399,"vAlign":2849},"List(Of T)",[2846,3434,3435],{"width":3403,"vAlign":2849},"dynamically resizable",[2846,3437,2869],{"width":3407,"vAlign":2849},[2843,3439,1295,3440,1295,3443,1295,3446,1295],{},[2846,3441,3442],{"width":3399,"vAlign":2849},"Queue(Of T)",[2846,3444,3445],{"width":3403,"vAlign":2849},"FIFO collection",[2846,3447,2869],{"width":3407,"vAlign":2849},[2843,3449,1295,3450,1295,3453,1295,3456,1295],{},[2846,3451,3452],{"width":3399,"vAlign":2849},"SortedDictionary(Of K, V)",[2846,3454,3455],{"width":3403,"vAlign":2849},"sorted set of name\u002Fvalue pairs",[2846,3457,2869],{"width":3407,"vAlign":2849},[2843,3459,1295,3460,1295,3463,1295,3466,1295],{},[2846,3461,3462],{"width":3399,"vAlign":2849},"Stack(Of T)",[2846,3464,3465],{"width":3403,"vAlign":2849},"LIFO collection",[2846,3467,2869],{"width":3407,"vAlign":2849},[2843,3469,1295,3470,1295,3473,1295,3476,1295],{},[2846,3471,3472],{"width":3399,"vAlign":2849},"LinkedList(Of T)",[2846,3474,3475],{"width":3403,"vAlign":2849},"doubly linked list",[2846,3477,2869],{"width":3407,"vAlign":2849},[2843,3479,1295,3480,1295,3483,1295,3486,1295],{},[2846,3481,3482],{"width":3399,"vAlign":2849},"ReadOnlyCollection(Of T)",[2846,3484,3485],{"width":3403,"vAlign":2849},"readonly set of items",[2846,3487,2869],{"width":3407,"vAlign":2849},[32,3489,3490,3491,3379,3493,3495],{},"Public Function Test(Of T)(ByRef o1 as T, ByRef o2 as T) as T\n  ‘do something\nEnd Function",[321,3492],{},[321,3494],{},"\nIt is possible to establish constraints with respect to the type of T.  The following is a complete list of the types of constraints:\nOf T as Structure > the type parameter must be a value type (ie. structure)\nOf T as Class > the type parameter must be a reference type (i.e. classes)\nOf T as New > the type parameter must have a default constructor\nOf T as NameOf BaseClass > the type parameter must be derived from the class specified by NameOfBaseClass\nOf T as NameOfInterface > the type parameter must implement the interface specified by NameOfInterface",[32,3497,3498,3499,3379,3501,3503],{},"’new items must have a default constructor\nPublic Class TestClass(Of T as New)\n  ‘stuff here\nEnd Class",[321,3500],{},[321,3502],{},"\nThe term generic can apply to Interfaces as well. In any case the interface will define the contract that the implementing class must adhere to.  When implementing a generic interface the supporting type specifies the placeholder type:",[32,3505,3506],{},"Public Interface IMyInterface(Of T)\n  Function Add(ByVal x as T, ByVal y as T) as T\nEnd Interface",[32,3508,3509],{},"Public Class MyClass\n  Implements IMyInterface(Of Integer)",[32,3511,3512],{},"Public Function Add(ByVal x as Integer, ByVal y as Integer) as Integer\n  Return x + y\nEnd Function",[32,3514,3515,3516,3518],{},"By all means utilize the generic collection namespace over the system.collection nongeneric namespace.  In addition to improved performance(avoiding boxing\u002Funboxing) your code will avoid type-safety issues of earlier releases of .NET.",[321,3517],{},[309,3519],{"style":3520,"src":3521,"alt":11},"display: none;","\u002Farticles\u002Fimages\u002Ffeet.jpg",{"title":11,"searchDepth":12,"depth":12,"links":3523},[],"2015-04-20T08:07:15.7900000-04:00",{},"\u002Farticles\u002Fgenericcollection-usage-in-the-net-framework",{"title":2823,"description":28},"articles\u002Fgenericcollection-usage-in-the-net-framework",[18],"HVNZe5xrJpyaU0pq3szPwlINvtqAJ9ix-JzG7RGvBtg",{"id":3532,"title":3533,"author":1188,"body":3534,"createdAt":3598,"description":3538,"extension":15,"img":3599,"meta":3600,"navigation":19,"path":3601,"seo":3602,"stem":3603,"tags":3604,"updatedAt":3598,"__hash__":3605},"articles\u002Farticles\u002Fnullable-types-in-net-framework.md","Nullable Types in .NET Framework",{"type":8,"value":3535,"toc":3596},[3536,3539,3542,3557,3563],[32,3537,3538],{},"Within the .NET Framework data types such as Boolean can either be true or false. Right? Well, with the release of 2.0 Framework it has been possible to create nullable data types. A nullable type can represent all the values of the underlying type plus empty (or undefined). In the case of our Boolean it would be True\u002FFalse and Nothing.",[32,3540,3541],{},"It is only possible to create a nullable types Nullable(Of T) for value types since the default value for reference types is already nothing. The following types are valid as nullable: Boolean, Byte, Int16, Int32, Int64, Single, Double, Decimal, DateTime. The following examples show examples on how to create a nullable variable type:",[32,3543,3544,3545,3547,3548,3550,3551,3553,3554,3556],{},"Dim success as New Nullable(Of Boolean)()",[321,3546],{},"\nDim customerId as New Nullable(Of Integer)()",[321,3549],{},"\nWith the release of .NET 3.5 it is also possible to use the short form versions:",[321,3552],{},"\nDim success as Boolean?\nDim customerId as Integer?",[321,3555],{},"\nIn C#",[32,3558,3559,3560,3562],{},"bool? success;",[321,3561],{},"\nint? customerId;",[32,3564,3565,3566,3568,3569,3571,3572,3574,3575,3577,3578,3580,3581,3583,3584,3587,3588,3590,3591,3593,3594,1721],{},"To check of a nullable type as a value it is possible to use the HasValue or Value properties. Use the System.Nullable.GetValueOrDefault property return either the assigned value, or the default value for the underlying type.",[321,3567],{},"\nIf customerId.HasValue Then\ndo something\nEnd If",[321,3570],{},"\nIf assigning a nullable type to a non-nullable type you must cast operator is necessary. For example:",[321,3573],{},"\nint newCustomerId = (int)customerId; \u002F\u002F in C#",[321,3576],{},"\nNullable types can be useful when dealing with NULL values from a database query however they are not the same. That is to say that DBNULL value is not the same as Nothing. When returning data from the database the following code will be necessary:",[321,3579],{},"\nint? customerId = null;",[321,3582],{},"\nif (!DBNULL.Value.Equals(reader",[45,3585,3586],{},"“CustomerId”",")){ \u002F\u002F this code converts the DBNULL to a c# null",[321,3589],{},"\ncustomerId = (int)reader",[45,3592,3586],{},";",[321,3595],{},{"title":11,"searchDepth":12,"depth":12,"links":3597},[],"2015-04-20T08:07:15.7000000-04:00","\u002Farticles\u002Fimages\u002Fstation.jpg",{},"\u002Farticles\u002Fnullable-types-in-net-framework",{"title":3533,"description":3538},"articles\u002Fnullable-types-in-net-framework",[18],"JNUKjLzLY5rs-w8jF4EkEer1CjSLRZAYa-LqJjqkYlU",{"id":3607,"title":3608,"author":1188,"body":3609,"createdAt":3963,"description":3964,"extension":15,"img":3960,"meta":3965,"navigation":19,"path":3966,"seo":3967,"stem":3968,"tags":3969,"updatedAt":3963,"__hash__":3970},"articles\u002Farticles\u002Fdesign-guidelines-classes-vs-structures.md","Design Guidelines– Classes vs. Structures",{"type":8,"value":3610,"toc":3961},[3611,3624,3727,3742,3747,3749,3777,3897,3903,3932,3935,3955,3958],[32,3612,3613,3614,3616,3619,3620,3623],{},"My goal is to cover some .NET 4 Platform features through a series of ‘guideline’ type entries demonstrating some new and existing functionality.  In this first entry, I have seen both classes and structures used throughout applications.  The following is meant to describe and explain good design considerations.",[321,3615],{},[394,3617,3618],{},"Structure"," types are well suited for modeling mathematical, geometrical, and other \"atomic\" entities in your application. A ",[394,3621,3622],{},"structure"," (like an enumeration) is a user-defined type; however, structures are not simply a collection of name\u002Fvalue pairs. Rather, structures are types that can contain any number of data fields and members that operate on these fields.",[2931,3625,1295,3627,1295],{"id":2933,"style":3626},"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;",[2931,3628,1295,3630,1295,1295,3637,1295,1295,3644,1295,1295,3653,1295,1295,3660,1295,1295,3662,1295,1295,3667,1295,1295,3675,1295,1295,3678,1295,1295,3681,1295,1295,3683,1295,1295,3688,1295,1295,3695,1295,1295,3698,1295,1295,3700,1295,1295,3702,1295,1295,3707,1295,1295,3714,1295,1295,3722,1295,1295,3724,1295],{"id":2936,"style":3629},"text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;",[36,3631,3633,3636],{"style":3632},"text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;",[45,3634,3635],{"style":2943},"struct"," Point {",[36,3638,1782,3640],{"style":3639},"text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;",[45,3641,3643],{"style":3642},"color: #008000;","\u002F\u002F Fields of the structure.",[36,3645,1782,3646,1231,3649,3652],{"style":3632},[45,3647,3648],{"style":2943},"public",[45,3650,3651],{"style":2943},"int"," X;",[36,3654,1782,3655,1231,3657,3659],{"style":3639},[45,3656,3648],{"style":2943},[45,3658,3651],{"style":2943}," Y;",[36,3661,2869],{"style":3632},[36,3663,1782,3664],{"style":3639},[45,3665,3666],{"style":3642},"\u002F\u002F Add 1 to the (X, Y) position.",[36,3668,1782,3669,1231,3671,3674],{"style":3632},[45,3670,3648],{"style":2943},[45,3672,3673],{"style":2943},"void"," Increment() {",[36,3676,3677],{"style":3639},"        X++; Y++;",[36,3679,3680],{"style":3632},"    }",[36,3682,2869],{"style":3639},[36,3684,1782,3685],{"style":3632},[45,3686,3687],{"style":3642},"\u002F\u002F Subtract 1 from the (X, Y) position.",[36,3689,1782,3690,1231,3692,3694],{"style":3639},[45,3691,3648],{"style":2943},[45,3693,3673],{"style":2943}," Decrement() {",[36,3696,3697],{"style":3632},"        X--; Y--;",[36,3699,3680],{"style":3639},[36,3701,2869],{"style":3632},[36,3703,1782,3704],{"style":3639},[45,3705,3706],{"style":3642},"\u002F\u002F Display the current position.",[36,3708,1782,3709,1231,3711,3713],{"style":3632},[45,3710,3648],{"style":2943},[45,3712,3673],{"style":2943}," Display() {",[36,3715,3716,3717,3721],{"style":3639},"        Console.WriteLine(",[45,3718,3720],{"style":3719},"color: #006080;","\"X = {0}, Y = {1}\"",", X, Y);",[36,3723,3680],{"style":3632},[36,3725,3726],{"style":3639},"}",[32,3728,3729,3730,3732,3733,3735,3736,3738,3739,3741],{},"myPoint.X=100;\nmyPoint.Y=76;\nmyPoint.Display();",[321,3731],{},"\nYou can create a structure using new keyword which will use the structures’ default constructor.",[321,3734],{},"\ni.e. Point myPoint = new Point(); \u002F\u002F each field will be automatically set to its default value",[321,3737],{},"\nA custom constructor can also be created with a structure which allows you to specify the values of a field upon creation.",[321,3740],{},"\ni.e. Public Point(int xpos, int ypos)\nPoint p2 = new Point(50,50);",[32,3743,3744],{},[394,3745,3746],{},"Class",[394,3748],{},[32,3750,3751,3753,3754,3757,3758,3761,3762,3764,3765,3767,3770,3771,3773,3776],{},[394,3752],{},"A class is a user-defined type that is composed of field data (often called ",[401,3755,3756],{},"member variables",") and members that operate on this data (such as constructors, properties, methods, events, and so forth). Collectively, the set of field data represents the \"state\" of a class instance (otherwise known as an ",[401,3759,3760],{},"object","). The power of object-based languages such as C# is that by grouping data and related functionality in a unified class definition, you are able to model your software after entities in the real world.",[321,3763],{},"\nI am going to jump to some less known aspects of a class.",[321,3766],{},[401,3768,3769],{},"Default constructor",": By definition, a default constructor never takes arguments.  After allocating the new object into memory, the default constructor ensures that all field data of the class is set to an appropriate default value.\nCustom constructor:Allows the user with a simple and consistent way to initialize the state of an object directly at the time of creation.  Note however that as soon as you define a custom constructor the compiler removes the default constructor.  Thereby if you wish to continue to have both a default and custom constructors you must explicitly declare the default constructor.",[321,3772],{},[401,3774,3775],{},"Chaining constructors ","utilizes the ‘this’ keyword.  Understand that using the this keyword to chain constructor calls is never mandatory.  Notice in the example below however that the constructor Public Motorcycle(string name) takes one string argument but continues to call the additional constructor Public Motorcyle(int intensity, string name) via the this keyword i.e. this(0,name)",[2931,3778,1295,3779,1295],{"id":2933,"style":3626},[2931,3780,1295,3781,1295,1295,3787,1295,1295,3790,1295,1295,3797,1295,1295,3805,1295,1295,3807,1295,1295,3812,1295,1295,3817,1295,1295,3825,1295,1295,3836,1295,1295,3838,1295,1295,3845,1295,1295,3850,1295,1295,3852,1295,1295,3857,1295,1295,3866,1295,1295,3869,1295,1295,3875,1295,1295,3878,1295,1295,3881,1295,1295,3883,1295,1295,3886,1295,1295,3889,1295,1295,3892,1295,1295,3895,1295],{"id":2936,"style":3629},[36,3782,3783,3786],{"style":3632},[45,3784,3785],{"style":2943},"class"," Motorcycle",[36,3788,3789],{"style":3639},"{",[36,3791,2003,3792,1231,3794,3796],{"style":3632},[45,3793,3648],{"style":2943},[45,3795,3651],{"style":2943}," driverIntensity;",[36,3798,2003,3799,1231,3801,3804],{"style":3639},[45,3800,3648],{"style":2943},[45,3802,3803],{"style":2943},"string"," driverName;",[36,3806,2869],{"style":3632},[36,3808,2003,3809],{"style":3639},[45,3810,3811],{"style":3642},"\u002F\u002F Constructor chaining.",[36,3813,2003,3814,3816],{"style":3632},[45,3815,3648],{"style":2943}," Motorcycle() {}",[36,3818,2003,3819,3821,3822,3824],{"style":3639},[45,3820,3648],{"style":2943}," Motorcycle(",[45,3823,3651],{"style":2943}," intensity)",[36,3826,3827,3828,3831,3832,3835],{"style":3632},"    : ",[45,3829,3830],{"style":2943},"this","(intensity, ",[45,3833,3834],{"style":3719},"\"\"",") {}",[36,3837,2869],{"style":3639},[36,3839,2003,3840,3821,3842,3844],{"style":3632},[45,3841,3648],{"style":2943},[45,3843,3803],{"style":2943}," name)",[36,3846,3827,3847,3849],{"style":3639},[45,3848,3830],{"style":2943},"(0, name) {}",[36,3851,2869],{"style":3632},[36,3853,2003,3854],{"style":3639},[45,3855,3856],{"style":3642},"\u002F\u002F This is the 'master' constructor that does all the real work.",[36,3858,2003,3859,3821,3861,3863,3864,3844],{"style":3632},[45,3860,3648],{"style":2943},[45,3862,3651],{"style":2943}," intensity, ",[45,3865,3803],{"style":2943},[36,3867,3868],{"style":3639},"  {",[36,3870,1782,3871,3874],{"style":3632},[45,3872,3873],{"style":2943},"if"," (intensity > 10)",[36,3876,3877],{"style":3639},"    {",[36,3879,3880],{"style":3632},"      intensity = 10;",[36,3882,3680],{"style":3639},[36,3884,3885],{"style":3632},"    driverIntensity = intensity;",[36,3887,3888],{"style":3639},"    driverName = name;",[36,3890,3891],{"style":3632},"  }",[36,3893,3894],{"style":3639},"...",[36,3896,3726],{"style":3632},[32,3898,3899,3902],{},[401,3900,3901],{},"Optional Arguments"," allow you to define supplied default values to the incoming arguments.  i.e. with the constructor below the user can create a new RocketShip with zero, one or two arguments.  This is a .NET 4 feature only.\nRocketShip = new RocketShip();\nRocketShip = new RocketShip(name:=”TestShip”);\nRocketShip = new RocketShip(10); \u002F\u002Fsets speed = 10, leaving name =  ””",[2931,3904,1295,3905,1295],{"id":2933,"style":3626},[2931,3906,1295,3907,1295,1295,3912,1295,1295,3926,1295,1295,3929,1295,3726],{"id":2936,"style":3629},[36,3908,3909],{"style":3632},[45,3910,3911],{"style":3642},"\u002F\u002F Single constructor using optional args.",[36,3913,3914,3916,3917,3919,3920,3922,3923,3925],{"style":3639},[45,3915,3648],{"style":2943}," RocketShip(",[45,3918,3651],{"style":2943}," speed = 0, ",[45,3921,3803],{"style":2943}," name = ",[45,3924,3834],{"style":3719},"){",[36,3927,3928],{"style":3639},"  driverSpeed = speed;",[36,3930,3931],{"style":3632},"  driverName = name;",[394,3933,3934],{},"Classes vs. Structures Guidelines",[366,3936,3937,3940,3943,3946,3949,3952],{},[369,3938,3939],{},"Consider defining a structure instead of a class if instances of the type are small and commonly short-lived or are commonly embedded in other objects.",[369,3941,3942],{},"Do not define a structure unless the type has all the following characteristics:",[369,3944,3945],{},"It logically represents a single value, similar to primitive types (integer, double, and so on).",[369,3947,3948],{},"It has an instance size smaller than 16 bytes.",[369,3950,3951],{},"It is immutable.",[369,3953,3954],{},"It will not have to be boxed frequently.",[1293,3956,3957],{},"  \nIf one or more of these conditions are not met, create a reference type instead of a structure. Failure to adhere to this guideline can negatively impact performance.  \n",[309,3959],{"style":3520,"src":3960,"alt":11},"\u002Farticles\u002Fimages\u002Fstructure2.jpg",{"title":11,"searchDepth":12,"depth":12,"links":3962},[],"2015-04-20T08:07:14.6400000-04:00","My goal is to cover some .NET 4 Platform features through a series of &lsquo;guideline&rsquo; type entries demonstrating some new and existing functionality.",{},"\u002Farticles\u002Fdesign-guidelines-classes-vs-structures",{"title":3608,"description":3964},"articles\u002Fdesign-guidelines-classes-vs-structures",[18],"-N3gPMr8ZsjnQA0jdKCMNLjbID8lUwbxN-6kUVEFlhA",1781574759674]