« first day (3410 days earlier)      last day (1521 days later) » 

2:09 AM
Happy Weekend !
 
 
5 hours later…
6:51 AM
happy weedstart
 
 
2 hours later…
8:48 AM
mornng.
 
9:01 AM
orning
 
mr5
rning
 
ing
Welp :(
 
10:41 AM
What is the interface used to clone object's value.. I heard that ICloneable is deprecated
 
11:10 AM
It's not deprecated, it's just that the docs recommend against it because it doesn't enforce any particular type of cloning operation
 
11:39 AM
There's no simple, generic, reliable and perfomant way to clone any object.
 
Morning o/
 
but in Clone method, isn't returning new Foo {Bar = this.Bar}; will use the Bar's ref?
 
11:55 AM
@mshwf Exactly.
It will perform a shallow copy, reusing Bar, if it's a reference type.
That might be what you want. It might not be. It's hard to say in a universal, generic manner.
And it's hard to create a new instance of Bar, because that might not be a trivial initialization either.
 
I want o use reflection but not sure if iOS will handle it
 
A common pattern - not the most performant, but certainly the easiest to use - is to serialize to JSON and deserialize back.
 
which will often fail on interfaces
 
@Wietlol It might, yes.
 
or any other kind of polymorphism
 
11:57 AM
@Wietlol Yup. We've found ourselves building glorious hacks to circumvent that.
 
But the serialise/deserialise is by far the easiest way to deep copy something
 
there is a way to serialize to json with type information
if that is what you meant
 
Android studio call chart for a Xamarin forms app...
 
i see a distortion error
or... a call chart
that was my second quess, I swer
 
@Wietlol JSON.NET supports including type information with the serialized JSON, but it's not a universal solution.
@CaptainObvious Is it... is it trying to spell something with the cyan highlights?
There's a word there, trying to get into focus.
 
12:33 PM
FFS I found out why my blazor app cant do a simple POST
[JsonConverter(typeof(JsonStringEnumConverter))] breaks it
 
Wait what
But it converts enums to strings and back anyway
 
12:49 PM
Enums are usually sent as their int value
If you want them as their names in the json, you'll have to tell the serializer explicitely.
 
1:41 PM
I have my blazor app and webapi hosted on different ports on localhost. Therefore I need CORS. So I added that to the webapi startup:
.AddCors(opts => opts.AddDefaultPolicy(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()))
What else do I need? When the blazor app does a request, the OPTIONS still comes back with "missing token 'content-type' in CORS header 'Access-Control-Allow-Headers', which seems logical since that header isn't even present.
Also I have .UseCors() in the Configure method, as described by MS docs.
 
 
2 hours later…
user12870752
3:44 PM
Hi all, I need help
 
user12870752
Is Rob out there?
 
hi
help with?
 
user12870752
A Linq query
 
user12870752
hmm.. yep same data but some different requirement
 
user12870752
3:51 PM
Bob's code-

students
.Select((s, i) => new { Student = s, Index = i})
.GroupBy(s => s.Student.GroupId)
.Select(g => new {
Students = g,
NumPassed = g.Count(gg => gg.Student.Status == "Passed"),
NumFailed = g.Count(gg => gg.Student.Status == "Failed"),
})
.SelectMany(g =>
g.Students.Where(gg => gg.Student.Status == "Passed")
.Skip(g.NumFailed == 0 || g.NumPassed == 1 ? 1 : 0)
)
.OrderBy(g => g.Index)
.Select(g => g.Student);
 
user12870752
His code works like charm.. No issues at all.. But I want to make a slight change.
 
user12870752
What this code does is-

Gets all students who-

1) Are "passed" the examination

2) If a group-

a) Contains both failed + passed students- get *all* the "passed" students in that group;

b) Contains only "passed" students- In this case, get all "passed" students except first "passed" student in that group

3) If a group contains only one "passed" student, that student should be omitted (Example: Group 2)

4) Preserves original grouping
 
oh a lot of things :P
let me see
 
user12870752
sure :)
 
user12870752
Now the only problem is that when a group contains one "passed" student and other "failed" students, this Skips that sole "passed" student. I don't want to do that..
 
4:01 PM
so, let me see if i fully understand
what you are trying to accomplish is this one?
3) If a group contains only one "passed" student, that student should be omitted (Example: Group 2)
if you skip that you will get a list of failed, right?
 
user12870752
3rd condition I no longer want
 
user12870752
I want to get rid of 3rd condition I put
 
user12870752
It's my mistake actually. Rob did help.. I was confused
 
can you try this?
students
.Select((s, i) => new { Student = s, Index = i })
.GroupBy(s => s.Student.GroupId)
.Select(g => new
{
Students = g,
NumPassed = g.Count(gg => gg.Student.Status == "Passed"),
NumFailed = g.Count(gg => gg.Student.Status == "Failed"),
})
.SelectMany(g =>g.Students)
.OrderBy(g => g.Index)
.Select(g => g.Student)
 
user12870752
4:12 PM
Thanks, lemme try
 
user12870752
I tried
 
user12870752
But it don't implement (a) and (b) conditions above
 
user12870752
a) Contains both failed + passed students- get *all* the "passed" students in that group;

b) Contains only "passed" students- In this case, get all "passed" students except first "passed" student in that group
 
students
.Select((s, i) => new { Student = s, Index = i })
.GroupBy(s => s.Student.GroupId)
.Select(g => new
{
Students = g,
NumPassed = g.Count(gg => gg.Student.Status == "Passed"),
NumFailed = g.Count(gg => gg.Student.Status == "Failed"),
})
.SelectMany(g =>
g.Students.Where(gg => gg.Student.Status == "Passed")
.Skip(g.NumFailed == 0 ? 1 : 0)
)
.OrderBy(g => g.Index)
.Select(g => g.Student);
 
user12870752
Lemme check
 
4:26 PM
wait i guess is wrong
because you want to exclude the ones that are failed
so this .Skip(g.NumFailed == 0 ? 1 : 0) should be .Skip(g.NumFailed == 1 ? 1 : 0)
 
user12870752
hmm
 
user12870752
.Skip(g.NumFailed == 0 ? 1 : 0) was correct :)
 
user12870752
Thank you so much :)
 
oh great :D
no problem :D
 
 
1 hour later…
5:51 PM
I have a question of the type that cannot be posted as a legal SO question,
and the problem is two days old now
I have a StateManager class that has a Dictionary<string,object> field and 4 methods: GetItem, SetItem, DeleteItem and DeleteAll.. the only way to add an object to the dictionary is by SetItem method, however there is an object that constantly changes without even calling the SetMethod
I thought the problem is that the object reference changes, but I used different approaches to only save the value of the object not the reference, but the problem still
 
What do oyu mean the value only
Everything you save as an object is a reference. So you either save a reference to that object, or you a reference to a copy of that object.
Do you copy the object and add that to the dictionary?
In that case, do you do a proper deep copy?
 
@Squirrelkiller yes, that waht I meant
@Squirrelkiller I used reflection and used MemberwiseClone
 
If you don't have an explicit impleemntation of that yourself, you'll usually get a shallow copy, meaning any reference types within the object will be the same objects
Recursively? I'm not sure how MemberwiseClone works.
 
by reflection there should be no reference transition
 
Should?
I'd actually try it. Make an object with nested references, clone that using your method, check if everything is cloned
 
6:01 PM
also part of the weirdness of the issue, is that the point that the object changes at it (by looking through watch) is entering some method, not even changing any object!
 
6:26 PM
what would be the easiest and good practice for a equality check of two Tuple<int,int,int,int> values ?
 
6:42 PM
Tuple already handles the Equals method nicely
 
 
3 hours later…
9:43 PM
@Squirrelkiller i see you made a PR for jack
 
10:29 PM
@CaptainSquirrel I see you completed it.
 

« first day (3410 days earlier)      last day (1521 days later) »