« first day (3378 days earlier)      last day (1571 days later) » 
00:00 - 13:0013:00 - 23:00

user47589
12:33 AM
If you go on an adventure, do not forget your bard
 
12:52 AM
Please ping me if you respond my question below.

I still don't understand why .net core DI does not throw exception for singleton referring transient while it throws exception for singleton referring scoped.
In my mental model, I think for both cases the DI must throw exception because both transient and scoped have shorter lifetime than singleton. Singleton should not enclose shorter lifetime injected objects.
 
user47589
1:23 AM
transient dependencies last as long as the thing using them exists. once that thing ceases to be, the transient dependency is cleaned up.
 
user47589
scoped dependencies end when their scope ends.
 
user47589
transient dependencies can last as long as the singleton does.
 
user47589
scoped dependencies cannot.
 
user47589
transient dependencies are saying "i'm here for you for as long as you need me. if that's forever, then so be it. I'm all in." scoped dependencies are saying "i'm here until dinnertime but then i got to go."
 
user47589
the singleton lasts past dinnertime. so the scoped dependency cannot fulfill the singleton's needs.
 
3:27 AM
I admire him for asking opinions on a buggy trash
meanwhile on my searchbar, was unclickable
irony
 
 
2 hours later…
5:05 AM
 
 
2 hours later…
6:39 AM
@Amy Is it possible for singleton to control the scope lifetime?
 
mr5
7:16 AM
@MoneyOrientedProgrammer that is the responsibility of the container in Dependency Injection
 
Goooooooooooooooooood morning
 
mr5
7:38 AM
o/
 
@mr5 Thank you!
 
8:00 AM
GoOoOoOoOoOoOoOoOoOoOoOd Mornin' squirrelerinos!
 
8:49 AM
o/
 
I'm sick. o_o
 
good morning
 
I didn't even come in to work monday and tuesday
I guess I should have taken three sick days instead of two, but here I am..
 
You're not helping anyone making everyone in the office sick.
 
9:05 AM
No, but there was something I needed to do today
Also, I've isolated myself in a separate room, because I legit don't want anyone to get sick because of me
 
As far as I know, the built-in .net core DI only allows constructor injection. However, I just read that a custom middleware can have a method called Invoke or InvokeAsync that can accept additional parameters that are populated by DI. How can it be possible?
 
you dont inject a constructor, you inject an instance
 
constructor injection means that the container injects dependencies via constructors.
 
the methods AddTransient, AddScoped and AddSingleton have a lambda argument which can specify how to construct the instance
 
Hello Everyone.
any idea how can I pull this off
0
Q: Set value of property in IQueryable<T>

Safi MustafaI am implementing Authorization for WPF. I have bound permissions with screens. For example, there is a screen called floor. It has four permissions associated with it. View Floor Add Floor Edit Floor Delete Floor Along with every permission we have four levels of permissions. All Self Rol...

 
9:12 AM
@MoneyOrientedProgrammer is that an actual term?
 
@Wietlol It is not about registering services.
 
I want to whack the person who invented it
if it is not about registering services, can you give an example?
 
somethign something no because it's barely an hour old
Also the question isn't clear. What are you asking. And "how do I do x" and just dumping a load of code is not a good question.
 
9:16 AM
@SafiMustafa the question is quite new, give SO a moment to read it and come up with an answer
;)
@MoneyOrientedProgrammer not sure how that would work
 
@Wietlol In Simple question is to apply a join on an Iqueryable and add a value to select clause.
 
since, the code invoking that invoke method would then have to be the DI container
which I think is kind of weird
the only way I have used DI is to construct instances
 
In webapi, data binding can be from DI container but we need [FromServices] modifier before method parameters.
 
those instances, according to my guidelines, must be fully constructed, not depending on the container being present and providing more stuff on the go
 
Another irrelevant question goes here. Consider the following code snippet.
public Task<string> GetElidingKeywordsAsync(string url)
{
    using (var client = new HttpClient())
        return client.GetStringAsync(url);
}
According to blog.stephencleary.com/2016/12/eliding-async-await.html, the flow of control is as follows.
With GetElidingKeywordsAsync, the code does this:

1. Create the HttpClient object.

2. Invoke GetStringAsync, which returns an incomplete task.

3. Disposes the HttpClient object.

4. Returns the task that was returned from GetStringAsync.
What I need to know is:
Right before disposing HttpClient, the result of GetStringAsync is already cached?
 
@MoneyOrientedProgrammer nope
because there is no result yet
 
@Wietlol the httpclient gets disposed while the background task is still running?
 
1. Create HttpClient
2. Invoke GetStringAsync
3. Task's initial process runs
4. HttpClient gets disposed
5. Task's followup process runs
that is the order
if the http client is required for the followup process, then this would break
 
2. is not running. There is no await
 
oh, it is running iirc
it will run until the first async call
at which point, it will either wait until being awaited to continue or pull a thread from a pool to continue when able
 
9:34 AM
my bad. It will run
 
but this is only from my memory, so may not be 100% true
 
or will it?
 
what a dangerous method
 
^
best is to keep the httpclient active until you are guaranteed to have a result
 
@MoneyOrientedProgrammer IMHO it's not cached. But I don't know if it's possible if the GetStringAsync is fast enough can it return a value
or will it be invoked either case after disposing the HttpClient
 
9:39 AM
OK folks for the discussion. I am thinking of ... :-)
 
Morning
 
mr5
or just await the result before disposing the http client
 
Meeting underway, 50 minutes, they still haven't talked about anything related to my tasks
I really didn't miss these meetings
 
the method is run depends on the design, if that uncompleted task's check for the referenced class if disposed OR that task uses one of the component that is disposed, you now have a dinosaur
 
mr5
not that I recommend to dispose http client though
 
9:41 AM
just await the result before disposing, there is no downside...
 
@HéctorÁlvarez if they are talking about if any of your tasks will be needed... It's "anything related to your tasks"
 
@MoneyOrientedProgrammer Or. If you really want a delayed query for every place where GetStringAsync is used, you can put the using (var client = new HttpClient()) inside the GetStringAsync
 
mr5
@Wietlol does it compile?
 
it runs...
 
mr5
9:47 AM
async is a keyword yk
 
but dotnet fiddle is being weird and doesnt seem to allow Task.Delay
 
@Wietlol Task.Delay is not trustable below 25 millisec
 
@mr5 not reserved tho
@ntohl what do you mean with "trustable"?
 
mr5
 
They are discussing 3 tools that I have no idea about, which are client developments and are nowhere close to what I do
 
9:48 AM
looking at the implementation, I just need any positive number
 
17
Q: How accurate is Thread.Sleep(TimeSpan)?

mezoidI've come across a unit test that is failing intermittently because the time elapsed isn't what I expect it to be. An example of what this test looks like is: Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); TimeSpan oneSecond = new TimeSpan(0, 0, 1); for(int i=0; i<3; i++) { Thr...

 
i dont need it to be accurate, just be a non-result task
 
mr5
@Wietlol so there's "reserved" and there's "keyword" hmm
 
I seen somewhere official say it would allow up to 7ms accuracy
 
if I use Task.Delay(0), I get an immediate result, which is similar to calling GetStuff(false)
using Task.Delay(1) (which might not be accurate), I get a running task, which needs to be awaited, therefor producing a callback continuation process, signifying the point I was trying to make
@mr5 in C#, the names are reserved keywords and contextual keywords
 
9:52 AM
\0
°/
 
for example, value is a perfectly fine parameter, right?
but it is a keyword inside a property setter body
 
Boolean async YUCK
 
mr5
haha
wietlol being sucky at naming and choosing types
 
shiiibaa time
 
Delay and Sleep will not be accurate because context switch might allocate CPU time in uncertain ways. That is why both method should not be used for timing. :-)
 
9:55 AM
!~shiba
 
huh
 
Wietlol just not caring, yuck + no-yuck is still yuck
so I dont care about naming in C# :D
 
so far away, approaching fast
 
mr5
@MoneyOrientedProgrammer how about if we .ConfigureAwait(false)?
@Wietlol ohhhhhhh didn't know that
they should also make the "object" a contextual keyword
 
9:57 AM
public class var
{

}

public static void Main()
{
    var var = new var();
}
 
mr5
object object = new object()
 
@mr5 Never use Sleep and Delay for accurate timing. I read from C# Essential that both might be started with some delay. :-)
 
mr5
@Wietlol var void = new class()
 
note to self: do not use Task.Delay to showcase an async proces' flow
@mr5 in Wietlang, all keywords are contextual
 
@Wietlol your true case just could write the false cases output easily
 
9:59 AM
@ntohl depends
 
yeah. Depends on the Delay's length :D
 
for delay 1?
 
it might happen, that in the Delay(1)'s runtime it doesn't give back the context to the Example
so the second output is shown
just like with Delay(0)
 
so... if I run it a few times, should I get the same output as Delay(0) at some point?
invoking it a million times and all have the same output as my example
mind you that this code will not compile for any of you tho :D
 
hmm. Something grants switching synchronization context, but it's special case than
 
10:11 AM
it doesnt matter how long it runs
it matters which thread is used and when the invocation is forced
 
10:24 AM
so when await Task.Delay(1) runs on another thread which's context is immediately run and finished before the initiating thread can output "Example::3", than you should have the second output.
 
probably
 
If you're thinking this hard about context switches, threads, and the exact timing of a delay when using tasks... you're probably using the wrong tool for the job.
 
the initiating thread will run until there is an async call, which in the case of delay > 0, it would be on that delay
 
we are analyzing the tools available.
 
after that, it will pop back out of the stack frame continuing on the calling method
 
10:27 AM
@ntohl For which use case, specifically?
 
when it calls the await, it checks the task's status
if it is idle, then it incokes the continuation
 
@RoelvanUden web api calls/ not blocking the UI/ background process on each file. You name it
 
if it is running because of another thread... im not sure what the result is
 
@ntohl That's exactly what tasks are for. You can just use them and not worry about the specifics.
 
but you have to be careful when using them
1 hour ago, by Money Oriented Programmer
public Task<string> GetElidingKeywordsAsync(string url)
{
    using (var client = new HttpClient())
        return client.GetStringAsync(url);
}
for example in that case
 
10:29 AM
That's just being bloody stupid.
 
but the compiler wont give you a heads up tho
 
it gives... There is no await in your async stuff
 
this might slip past you and break everything
its not async tho
 
You have to remember two things:
1. `await` anything that returns a `Task`
2. and if you don't, consider the implications of scopes and exception handling
That's it.
The moments when you're NOT awaiting something that returns a Task is when you should really consider what it is you're doing
Otherwise, be happy, and just smack async/await around.
 
that doesnt make me happy tho
 
10:31 AM
Does anything make you happy?
 
just look at the linq chain I posted earlier
await be like "ye, let me make it fugly for you"
 
Can't find it, show me?
 
and C# be like "ye, the solution to that fugly thing just postpones the problem"
 
Don't show him, it's trap
 
keep in mind, this is not using C# 8
 
10:33 AM
What's wrong with that?
 
its ugly
> .Select(async it => await it.Example(true))
this returns an IEnumerable<Task<T>>
 
You could split up the two responsibilities of linq blocks into two vars.
Other than that, eh, it's fine.
 
the await part doesnt split the responsibilities tho
and ye, vars are ugly too
 
I'd put the task await into a var, then process on that.
You think everything is ugly :-)
 
no, I dont
starts up a Kotlin project
 
10:37 AM
Anyway, it makes no sense to over-complicate these mechanisms just because your sense of aesthetics convinced you it's ugly. These mechanisms exist for a reason. Use them.
 
ye... no
I would avoid them if possible
mostly because they yield no benefits for me
 
the only use case I can think of is starting multiple tasks and then awaiting them all
I have no blocking on ui thread
I have no making available for concurrent calls of a web service
I have no input/output delegation
 
You have no useful programs
 
the only thing I could have is input/output concurrency on a single request
which is rare
@ntohl I just have an environment that deals with all of that stuff for me
 
10:39 AM
using tasks is an environment too
 
not one I like
since it has very little benefit for me, the only change I see is noise... and a load of them
 
wait wait... you are saying there is an environment which are doing stuff like "blocking on ui thread", and "making available for concurrent calls of a web service", and "input/output delegation" and you are not doing those... So which one?
do or do not. Do not wietlol
 
AWS
my web services are hosted in AWS Lambda
which is a containerized environment
each container is only allowed to do one call at the same time
if all containers are busy (which shouldnt happen because of scaling), a new instance would spin up
 
that's making available for concurrent calls of a web service. You immediately use that by choosing AWS
 
the ui we dont do in C#... but that could have the same environment
@ntohl one web service in Lambda does not do concurrent requests
it cannot
unless you make your own runtime which can
but then you are an idiot
vOv
 
10:44 AM
just curious, but what would you guys say to coding defensively to the extreme? Say in a database, you have a one to many relationship between two tables. The child should have exactly one parent, but say you checked for the case that there was more than one parent anyway..
is it justifiable to add checks for something that should never hold true?
the whole "never say never" idea..
 
@Neil You should have put your efforts to secure the parallel update of the parent field
 
I wouldnt do it until that thing that cant happen happened anyway
 
@ntohl well put aside for a second how you would handle that case.. would you even check for it if it should never be the case?
 
doing all those checks would take like double the development time
 
in time, everything can change of course.. but isn't it a little absurd to add checks for something which, as is, cannot be possible without overhauling db structure significantly?
I just see this check in code for just this type of situation.. it checks if there are no records.. perfectly legit check.. and then it checks if there is more than one.. which cannot be..
 
10:47 AM
@Neil it depends. If the db is only updated by services, than I would strongly recommend to NOT over defense yourself. If there is manual intervention to the database, it's questionable still
 
@Neil if it is logically dead code, you can remove it
 
@Wietlol hah, no, not going to step on someone's toes on such a trivial issue
just debating its usefulness
@ntohl well would it make a difference if it were enforced via constraint or not?
 
if it is logically dead code, it probably brings more harm than it gives you any benefit
 
@Wietlol fixing code in projects which aren't my own harms me more than it gives me any benefit
 
true
but that is just its usefulness
 
10:50 AM
I just saw that and wondered if I would have done the same in that circumstance
 
@Neil it's not true. Imagine the newcomer who have a question about "is this function does what I think it does", than the answer is "oh. This is dead code. Don't look at it" "I'm looking at it for 2 weeks now"
 
and I think the answer to that is, assuming I'm very sure of that that situation should never arise now or in the near future, it is safe to not check
@ntohl meh, it's not technically dead code. It's a PL-SQL method which returns a specific code when more than one record is found
so anyone calling would have to consider that possibility, since the method conceived of that possible return code
the situation should simply never happen based on how it is organized, that's all
 
the same goes to the overdefending case. You should not read validation code for cases which are prohibited by the system
 
Well I didn't know what possible values would get returned
but next time I'll cover my eyes if I see something prohibited ;)
 
@Neil to me, this sounds like Kotlin's null awareness in combination with not-directly null-aware capable code
for example, in Java's hashmap, you would do something like this
if (map.containsKey(key))
    String text = map.get(key);
text will never be null
in Kotlin, Map<K, V>::get returns V? because it returns null if the key is not found
so, in kotlin, the equivalent would be this
 
10:54 AM
@Wietlol map.put(key, null);
 
if (map.containsKey(key))
    val text: String? = map.get(key)
 
the value can still be null though
 
@Neil Map<String, String>
V is non-null
 
it can be null because key isn't found or because the value is literally null
 
so, the only way the value can be null is because of another thread removing the element just between those calls
 
10:56 AM
hmm, I suppose Kotlin wouldn't allow you to insert null values
 
considering this is an immutable hashmap...
@Neil only if you use Map<String, String?>
 
still, it could happen if the map was filled in java code
 
but still, the point is that you know the value is not going to be null
because you checked, you know that the map is immutable, you know that the values cannot be null
do you still want to do if (text == null) ?
 
I see your point.
If you know it can't be null, no point checking
but you'd have to be very sure on that point
in Kotlin, it's easy to know this, but in Java less so
 
in SQL, dont even try :D
 
10:59 AM
TDD can document + assert you these cases
 
@ntohl can it tho?
document, sure, assert? not so sure
 
@Wietlol every possible input is generated by a test. So there is a test for non null input, and if and only if there is a null case, there is a test for null
so non null cases, you don't write superfluous checking code, because it doesn't make anything green
code base is cleaner this way
 
there was a method parsing mathematical operators into a class with a binary function applying the operation
it supported "all the mathematical operators"
any non-mathematical operator would throw an exception
until... you find out that you forgot one case
you add it in the code, run all tests again, everything works
you never asserted that using that operator that you forgot would result in an error
TDD can assert happy flows... exceptional flows are a bit more difficult
 
when you add the "forgot" case, you have to deal with it like you are completely rewriting the whole class. So restart with the simple red case (which is an exceptional flow) make it green. Next red case. Make it green.
and ofc refactors in between
 
11:15 AM
Gah
Fucking edge cases
 
ye, use chrome instead
 
I thought something was ready to go
But got bamboozled when testing it in prod
 
Guys it took all morning but I finally can whistle loud without fingers
The things you learn while developing software...
now I have to perfect the technique
 
can you share the nuget package you used to learn it?
 
@HéctorÁlvarez I didn't know there were people who couldn't whistle without fingers
 
11:27 AM
I would guesstimate over half the world population
I make a high pitched noise, but don't quite manage the whistle yet
it comes randomly
until I learn the position
 
though I have heard some people can't roll their tongues
 
I believe everyone can, but it requires skill
 
my dad taught me how to turn an acorn cap into a whistle, and you can hit the 100 decibals easy with that
 
Meanwhile everyone can whistle, but I've been hissing and spitting at the screen for several hours with a light head.
 
good survival trick if you're ever lost in the woods I suppose
 
11:31 AM
In the woods?
Or... at your farm?
Squirrels come with that ability maxed out by default as racial skill
 
well there are acorns in the woods as well
 
no, that's a lie
acorns are an invention of squirrels
 
is that true @CaptainSquirrel?
 
i almost copy pasted my credit card here instead of the SMTP host at the other computer
But you'll never know
 
11:42 AM
@Hans1984 cuseng hari is da
 
:D
hes a fatty
eats a lot of acorns
 
@Squirrelintraining Say what?
 
cuseng
koseng
Thats like the getto way of saying cousin
 
WHO RELEASED THE SECRET?
@HéctorÁlvarez you were sworn to secrecy
You will not expect the Spanish inquisition Squirrels!
 
Oh no, not the Spanish squirrels!
 
11:57 AM
The sPAINish Squirrels!
 
noooooooo
 
Funny when people answer a question with "Sorry I didn't read your post but I think this is what you need"
 
:D
Soudns like me
 
This is how things work
 
12:14 PM
@HéctorÁlvarez I didn't read but you wrote, but I thought it was funny
 
12:51 PM
> Ok, I read what you wrote and to me, it sounds like this: "Oh no, my stuff isn't working. My life is meaningless now. I am so depressed. Boohoo."
 
00:00 - 13:0013:00 - 23:00

« first day (3378 days earlier)      last day (1571 days later) »