Click here to Skip to main content
14,578,180 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: I can hear the difference between linux and windows Pin
OriginalGriff19-Jan-20 20:43
mveOriginalGriff19-Jan-20 20:43 
PraiseRe: I can hear the difference between linux and windows Pin
the goat in your machine19-Jan-20 21:44
Memberthe goat in your machine19-Jan-20 21:44 
GeneralRe: I can hear the difference between linux and windows Pin
Mark_Wallace19-Jan-20 21:47
MemberMark_Wallace19-Jan-20 21:47 
GeneralRe: I can hear the difference between linux and windows Pin
honey the codewitch19-Jan-20 21:49
mvahoney the codewitch19-Jan-20 21:49 
GeneralRe: I can hear the difference between linux and windows Pin
Dan Neely20-Jan-20 5:00
MemberDan Neely20-Jan-20 5:00 
GeneralBut can it run Doom? Pin
honey the codewitch19-Jan-20 15:13
mvahoney the codewitch19-Jan-20 15:13 
GeneralRe: But can it run Doom? Pin
Super Lloyd19-Jan-20 18:14
MemberSuper Lloyd19-Jan-20 18:14 
Rant.NET Core 2.2 vs .NET Core 3.1 Pin
Marc Clifton19-Jan-20 13:24
mvaMarc Clifton19-Jan-20 13:24 
This is NOT a programming question. Just something you might want to be aware of.

So I migrated my project and fixed that various things in Startup that broke. Stupid things, like apparent env.IsDevelopment() doesn't exist anymore, and IHostingEnvironment has to be changed to IWebHostEnvironment or something like that, and app.UseMvc(); is wrong now and you have to use:
app.UseRouting();
app.UseEndpoints(endpoints =>
{
    // endpoints.MapRazorPages(); //Routes for pages
    endpoints.MapControllers(); //Routes for my API controllers
});

instead, and I don't have Razor pages anyways.

And I do wish that the whole NuGet package manager / Visual Studio would figure out that when I change the target framework, yes, please go and get the appropriate packages for the new framework, and now I need to specifically install the System.Data.SqlClient framework? And we're no longer using Microsoft.AspNetCore.App but instead need Microsoft.EntityFrameworkCore and Microsoft.EntityFrameworkCore.SqlServer?

Sigh. Fine, relatively easy fixes, and all that was an aside, relatively easy to fix, but annoying.

So, once I got it to compile, fired it up and tried a very simple API call that returns an access token.

Now, in .NET Core 2.2, the response at the client contains the key "access_token"

In .NET Core 3.1, the response at the client contains the key "token"

As in:
JSON.parse(xhr.response).access_token;

has to be changed to:
JSON.parse(xhr.response).token;

WTF?
On the C# side, the return from the API call is the same:
ActionResult<IAccessToken>(resp.token)

where IAccessToken is quite literally just:
public interface IAccessToken
{
    string Token { get; set; }
}

Now here's where it gets interesting. resp is actually a tuple: (IAccessToken token, HttpStatusCode status)

and I'm returning the token part of the tuple resp.token (checking the status is not necessary because if the status isn't "OK", then the token is null so the full line is actually:
ret = resp.token.Token == null ? Unauthorized() : new ActionResult<IAccessToken>(resp.token);
but that's irrelevant to this discussion.

The point being, .NET Core 2.2 serializes the container IAccessToken differently than .NET Core 3.1.

Good grief. I would not have expected that kind of a breaking change. Why the heck is 2.2 prepending "access_" to the key? And what else breaks in the serialization of objects with 3.1?

And (shame on me) why didn't I notice that weird "access_token" issue to being with? I even wrote up the example response in the documentation with that!

There's a lesson here somewhere. Don't trust .NET Core. Don't trust open source projects. And notice stupid things, because if I had, I could have at least forced it to return what I expected.

And here's another fun one. This code:
client = context.Client.SingleOrDefault(acct => acct.Token == token && (!acct.IsDeleted || allowDeletedAccounts));

Given:
[NotMapped]
public bool IsDeleted { get { return (Deleted ?? 0) != 0; } }

(yes, we have a Deleted flag as a nullable integer in our tables) - this code works fine in .NET Core 2.2.

But noooo, EF can't figure out what to do with it in .NET Core 3.1. So instead:

client = context.Client.SingleOrDefault(acct => acct.Token == token && (((acct.Deleted ?? 0) == 0) || allowDeletedAccounts));


And that breaking change isn't discovered until runtime! (Like the serialization issue when the client tries to parse out the token.)

So how many places in the code base break at runtime and you won't know until you've executed all the possible code path queries?

Now, while I had tried .NET Core 3.1 because there were posts about multi-part content being broken in .NET 2.2 and it was fixed in .NET Core 3.0, it turns out that that wasn't the reason my file uploads weren't working.

But that's a whole other story. Involving pretty much 8 hours of try this, google that, and getting so pissed off (which is rare for me) that I really wanted to just go on a rampage. Because, at the end of the day, it's quite simple, but nobody actually tells you the important things you need to make sure you do correctly. That will become an article, so that somewhere in the cloud there will be a concise example explaining why and not just glossing over the critical, key, pertinent, essential, vital niggly little things you need to do to post FormData up to a .NET Core application. Grrr.

GeneralRe: .NET Core 2.2 vs .NET Core 3.1 Pin
honey the codewitch19-Jan-20 15:15
mvahoney the codewitch19-Jan-20 15:15 
GeneralRe: .NET Core 2.2 vs .NET Core 3.1 Pin
Gerry Schmitz19-Jan-20 18:09
mveGerry Schmitz19-Jan-20 18:09 
GeneralRe: .NET Core 2.2 vs .NET Core 3.1 Pin
mmcdaniel20-Jan-20 3:33
Membermmcdaniel20-Jan-20 3:33 
GeneralRe: .NET Core 2.2 vs .NET Core 3.1 Pin
Richard Deeming20-Jan-20 8:46
mveRichard Deeming20-Jan-20 8:46 
GeneralI don't feel comfortable with this but i think it works Pin
honey the codewitch19-Jan-20 4:50
mvahoney the codewitch19-Jan-20 4:50 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 5:21
MemberMark_Wallace19-Jan-20 5:21 
GeneralRe: I don't feel comfortable with this but i think it works Pin
honey the codewitch19-Jan-20 5:33
mvahoney the codewitch19-Jan-20 5:33 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:06
MemberMark_Wallace19-Jan-20 21:06 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 9:12
mveOriginalGriff19-Jan-20 9:12 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:10
MemberMark_Wallace19-Jan-20 21:10 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 21:11
mveOriginalGriff19-Jan-20 21:11 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:13
MemberMark_Wallace19-Jan-20 21:13 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 21:28
mveOriginalGriff19-Jan-20 21:28 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:39
MemberMark_Wallace19-Jan-20 21:39 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 21:45
mveOriginalGriff19-Jan-20 21:45 
GeneralRe: I don't feel comfortable with this but i think it works Pin
Mark_Wallace19-Jan-20 21:54
MemberMark_Wallace19-Jan-20 21:54 
GeneralRe: I don't feel comfortable with this but i think it works Pin
OriginalGriff19-Jan-20 22:06
mveOriginalGriff19-Jan-20 22:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.