« first day (3511 days earlier)      last day (1444 days later) » 

6:22 AM
Buenos dias
 
7:19 AM
Nope, not enough routine for that I guess
 
7:35 AM
hi all
I made a windows form application via c#
in my program there is button name "update" when the button clicked it update my db everything works perfect
ı want to write a .bat file and it have to open exe and click the button
start "" "C:\Users\asdf\Documents\Visual Studio 2010\Projects\program\bin\Debug\program.exe"
it opens my exe but I can't find how to trigger button
 
8:00 AM
Just change the program to accept a command line parameter that makes it do whatever "update" does, then invoke your program from the bat like "myawesomeapp.exe --update-db"
 
give it an argument check for "no gui"
^ that
 
sorry ı dont understand :( its my first try to do it
 
8:17 AM
Your main method should take string[] args as an input parameter.
You check if there was a parameter passed to it, and if so, you trigger the update method from there.
Then you can call it from a .bat file like "program.exe runupdate"
And runupdate will be in the string[] args in the public void main
Anyone here used Magick.NET (ImageMagick) before? It throws an exception for me, something something type initializer something cant find native dll....
 
What le squirrel said. In your Main, you should decide what to do. Run the UI or do something else based on the input args.
@Squirrelkiller Magick.NET is just a wrapper for Magick.. it literally p/invokes magick. If it's not installed... its' not gonna work
 
I thought Magick.NET brings ImageMagick with it as embedded resource?
 
I'm wrong, then. Last time I used it, it definitely didn't.
 
> With Magick.NET you can use ImageMagick in your C#/VB.NET/.NET Core application without having to install ImageMagick on your server or desktop.
 
Alright, cool! Then I don't know and I'm sorry I wasted your time ;D
 
8:24 AM
Don't worry, everything pulling my thoughts in another direction is better then them going in circles ;)
 
What's the exact error?
 
Outer exception is "The type initializer for 'NativeMagickSettings' threw an exception "
Inner exception says cant find magick native dll / cant load module
I'm afraid the exact error comes in german and isn't very helpful in terms of googling
 
8:37 AM
Goooood morningish.
 
Hi Avner, nice to see you around!
How's it going?
 
Not bad, all things considering.
Kids are back in school and/or kindergarten.
Still working from home for the foreseeable future.
But things are reopening.
 
9:04 AM
Yeah germany is getting things more normal lately too.
 
yaay. Kindergarten open from Tuesday.
 
Need to get a new desk. I've been working on a repurposed plastic lawn table for the past couple of months. Since it seems that we'll be working from home until the end of the year, I should start investing a bit in a better workspace.
 
You...don't have an actual desk at home?
 
I do, and it has the home computer and monitor and everything. But ever since we started working from home, I set up a second workstation for me, with my monitor from work and everything.
But it's makeshift and... suboptimal.
The main home computer is used by my wife and daughter as well. I couldn't get any work done if I had to share it with the rest of the household.
 
That's unfortunate
 
9:30 AM
It's nice to have a second workstation. But I might as well accept that it's not going anywhere and get some decent furniture for it.
We're getting a fair expenditure allowance from work to cover it, actually. I can probably get a decent desk AND chair.
 
Oh nice! Consider getting a standup table :) you know, those you can just slide up and down so you don't sit all day.
 
I would consider a table extendible to bed :)
 
Anyone know how a newly with swashbuckle generated swagger endpoint containing exactly one controller method and one model can have "Invalid swagger 2.0 specification. Missing version property."?
Tried adding a REST api via VS2019
If I open the swagger json, there is clearly info.version
 
@Squirrelkiller Honestly, I'd rather sit all day.
 
9:45 AM
Have you tried it though? I feel it's relaxing to sometimes just stand for 20 minutes. Also helps with walking around when thinking about something.
 
I get backaches when standing. Walking is fine, but standing doesn't agree with me.
 
10:01 AM
Why would you want to stand up?
grab one of those things that look like bike pedals, and use them when idling
 
mr5
basically, make your bike as your chair
 
Why can't async mathods have in parameters? I get ref and out, but in?
 
10:19 AM
why is the in parameter that important?
 
It's not
But I'd rather use it than not use it
 
which async methods?
private async Task OnRequestToken(OAuthRequestTokenContext context) is valid
 
private async Task OnRequestToken(in OAuthRequestTokenContext context) is invalid
 
I haven't used in/ref/out parameters... ever
other than testing purposes of what they mean
 
mr5
@ntohl how did you exactly guess which method sqrqrlkiller is referring to?
I'm only using in,out in my generic interfaces for creating contra/covariance
 
10:33 AM
hmm. I have only C# 7 code at the moment
 
mr5
oh I think I used in before.
 
ah yes, me too, but those are different
 
it's 7.2
 
mr5
does ntohl and sqrlkiller are communicating with telepathy?
 
no, just with spyware
 
10:36 AM
@mr5 squirrelkiller copy pasted my message
 
mr5
but why would you give an example like that?
 
Technically I didn't copypaste it but typed it from your message
 
mr5
and why does sqlrkiller seems to be agreeing that it's the actual method he is referring to
 
Also: You can make contra/covariant generics with in/out type parameters?!
THat is awesome
 
the same keywords are used for that feature
also, it only works on interface type parameters iirc
which is absolutely bonkers
 
10:39 AM
@mr5 Because the topic concerns all methods in general, so any method would have been sufficient really.
Wow yeah it's completely useless on interface types lol
 
but yea, like how IEnumerable<out T> works
 
(Except in very special cases)
 
> Limitations on in parameters
You can't use the in, ref, and out keywords for the following kinds of methods:

Async methods, which you define by using the async modifier.
 
it is not useless on interface types... but it should be allowed on classes and functions as well
 
I can use ref in C# 7
 
10:40 AM
But not for async methods
 
my mistake
 
Which is ok. But in isn't a variable that gets sent back out of the context.
 
the reason for it is probably scoping
I think the in argument is not stored on the heap, but instead on the stack, in that case, an async function cannot use it since it cannot guarantee that the function completes before that stack frame gets removed
 
10:53 AM
Man, C# 9 is around the corner with some nice features, and I never even got to use 8's new stuff.
But yeah, @Wietlol's speculation sounds right. in parameters are explicitly not copied by value, and since async functions have no guarantee that they will execute before the surrounding context is cleared, they're disallowed. Similar to the possible problems of calling an async method in a using block, passing in the using-guarded variable.
 
do we have a list of expected C# 9 features?
 
Yeah, they were published a few days ago. The most interesting ones is data classes, I think - a revamping of the record classes that were proposed (but scrapped) for C# 6.
 
6? or 8?
I thought record classes were a thing already
 
I'm excited :D
Top-Level programs: C# is now a script language
 
10:58 AM
They added quite a bit of syntactic sugar. Init-only properties (`public string MyProp {get; init;}) is nice syntax for a common pattern.
C# 7 (I think) added the option to drop the set; and implicitly allow only constructor initialization, but I think the init keyword is clearer adn better.
 
hmm... the with expression is nice
 
init only properties is what I never knew I missed for years. Basically any time you use a result pattern, you'd need that. But couldn't make then get-only, because that breaks serializers.
 
@AvnerShahar-Kashtan I dont really like the pattern tho
what is the point of not using a proper constructor?
 
@Squirrelkiller I'm very meh about that. I mean sure, it's nice to be able to whip up a quick C# script, but it really feels like a loss off focus. You have PowerShell, and python, and plenty of other scripting languages.
@Wietlol Because you want a concise syntax for record classes, similar to Scala's case classes.
 
the problem with { get; } is that you cannot set the properties on init using the object initializer
 
11:01 AM
I think it also saves a bit of clutter for a Program.cs that is only new MainWindow().Run()
 
@Squirrelkiller Not entirely. JSON.NET, for instance, will scan for constructor parameters matching the field name and initialize using that ctor, if available.
 
@AvnerShahar-Kashtan you mean record class Person(String Name, DateTime DateOfBirth, Country Nationality); ?
I mean, you cant get more concise than that
 
The with expression is nice, yes. I've written so much boilerplate code for "mutating" immutable classes.
 
@AvnerShahar-Kashtan Oh nice, didn't know that. Does STJ do the same?
Oh burgers are here, smell ya later :D
 
@Squirrelkiller Dunno. It came out pretty much when I shifted off of C#. :)
 
11:03 AM
oh shit... the with expression is not nice... I thought it was something I know as "the with expression/function" but it isnt what I am familiar with
again... it solves one problem that the generic solution would solve equally well... except the generic solution solves a ton more problems
 
@Wietlol Oh it's very nice. It's basically functional programming.
 
I like it. Again, it's shorthand syntactic sugar for copying a POCO with minor changes.
 
ye, it is super nice... except when it is not
 
Basically, 90% of the features on that page are part of the "make it easy to define, use and pass around immutable record classes" uber-feature.
I like the extended pattern matching, though the syntax is starting to look very iffy.
 
11:05 AM
Mainly because the arrow operator is too similar to the comparison operators.
DeliveryTruck t when t.GrossWeightClass switch
{
    < 3000 => 10.00m - 2.00m,
    >= 3000 and <= 5000 => 10.00m,
    > 5000 => 10.00m + 5.00m,
},
That's too many >'s and ='s.
 
haha
 
But of course, if you ask me what change in C# 9 directly affects the most lines of code I've written in my lifetime, it's probably the tiny little not keyword.
Allowing you to do if (obj is not Customer) instead of if (!(obj is Customer).
 
> Top-level programs
YAAAAS
> using System;

Console.WriteLine("Hello World!");
dang it, I had my hopes up
still no top level functions
is not is nice tho
> Covariant returns
and that is probably going to be a big thing
as soon as we also have contravariant parameters
 
Yeah, they kinda buried the lede there, put it in as the last in a long list of features, but it's a big one.
Generations of developers wrote native inheritance hierarchies and crashed against the rocks of covariant return types.
 
damn....cyberpunk 2077 is coming out before J.Doe returns
 
11:23 AM
lambda parameter discards might also be fun
but yea... the exciting list imho
- Covariant returns
- not keyword (specifically in combination with other keywords)
- data classes (but I sure hope they thought about still allowing a body on them)
(and yes, with is not on that list)
 
@Freerey lol
J.Doe is screwed
 
when he comes back, he's gonna hear about what I'm doing with Naomi in my 4th run of the main story
 
:P
 
inb4 J.Doe arrives
I wonder why we don't have namespace declarations. I expect most code to be in files with a single class in a single namespace. Namespace declarations would clean it up one indentation, same as using declarations.
 
11:41 AM
He's always lurking
 
11:54 AM
@Squirrelkiller Yeah, that seems like a pretty low-hanging fruit to fix. Especially if you constrain the compiler to allow it only before all type definitions.
 
namespace declarations would also be fine
although, I dont really mind
my code doesnt indent far anywhere... so...
 
12:39 PM
ahoy mateys
 
Ahoy Captain o7
 
chipsa hoy
 
god why is azure so confusing
and why does it take so long for their portal to update with your costings
 
12:56 PM
!~shiba
 
1:09 PM
Ben Popper on May 27, 2020
We’re excited to share the results of our 10th annual developer survey! 65,000 developers shared their thoughts on the state of software today.
 
...there was a 2020 dev survey?
 
All those languages are above C#? Fuck.
I think I've heard of Julia and Dart
 
tbf I think many times C# is used in a business setting where updating is complicated, so it's not all C#8 and coreFx.
 
wait what
2020 dev survey???
 
Only the top 1% reputation holders were given the survey
 
1:23 PM
Dart looked interesting
 
everybody shure loves rust now
TIL Discord is written in Rust
maybe I should learn it
 
C#9 stole sooo much from F#
 
it is better to steal a good design than make a crappy one yourself
 
we still need discriminated union, than it's not a big difference between the 2 language
 
discrimination? pls no
 
1:30 PM
ValidEmail of string | NonValidEmail of ErrorDescription
 
a union type is like (String | Integer) right?
 
yeah
 
what is a discriminated union?
(Black | Nothing) ?
 
stealing is taking something and putting your own spin on it to make it better; copying is just taking the exact same thing with no changes
 
1:31 PM
ok. Than just copied
 
people always take Picasso's quote about stealing in the wrong direction
 
so... what can you do with discriminated unions that you cant do with normal unions?
 
> Sum types vs. C++ unions and VB variants
At first glance, a sum type might seem similar to a union type in C++ or a variant type in Visual Basic, but there is a key difference. The union type in C++ is not type-safe and the data stored in the type can be accessed using any of the possible tags. An F# discriminated union type is safe, and the data can only be accessed one way. It really is helpful to think of it as a sum of two types (as shown in the diagram), rather than as just an overlay of data.
 
sounds more to me that C++'s union types are just bork
in Kodian, there are 3 combined types
union types like (String | Integer | Boolean)
intersected types like (Collection<String> & Serializable)
and tuples like (Integer, String, String)
the way how union types work is that if you have a function like
    function format(value: Integer) -> String { ... }
and you have a value like
    value x: (Integer | Boolean) = ...
then you cannot call that function because the value might be a boolean
you have to do something to assert that it is an integer or to allow the function to accept the boolean
for example
if (x is Integer)
    format(x)
or, by changing the format parameter type or introducing an overload
in the case of overloads, the compiler produces a switch expression
function format(value: Integer) -> String { ... }
function format(value: Boolean) -> String { ... }
value x: (Integer | Boolean) = ...
value text: String = format(x)
the compiler transforms that last statement to
value text: String = when(x) {
    is Integer -> format(x)
    is Boolean -> format(x)
}
so, I assume that these are discriminated unions... right?
otherwise, I still dont understand the differences
 
in F# in every match expression you have to cover all cases. So if you match on a union type, you have to handle type Email = ValidEmail of string | NonValidEmail of ErrorDescription like let xy (inp : Email) = match inp with ... <- there you have to cover the cases
right
you can do let xy (inp : NonValidEmail variableContainingError) = ... too, but the calling place will cover, that the parameter mustn't be Email, but of the right type
Option<T> and Result<T, TError> are simple examples
 
1:53 PM
Is there a better way of checking if a file has one of a few extensions than Regex.IsMatch(fileName, @"\.heif$|\.heic$") ?
 
// The definition of Result in FSharp.Core
[<StructuralEquality; StructuralComparison>]
[<CompiledName("FSharpResult`2")>]
[<Struct>]
type Result<'T,'TError> =
    | Ok of ResultValue:'T
    | Error of ErrorValue:'TError
 
@Squirrelkiller how about fileName.EndsWith(x) ?
 
what fileName.in.out.exe would have as extension? exe, or [in, out, exe]?
 
and then just make a list of extensions
 
1:56 PM
like ListOf(".heif", ".heic").Any(it => fileName.EndsWith(it))
or yea, get the extension and then check if that exists in a collection
 
["heif", "heic"].Contains(Path.GetExtension(fileName))
 
@ntohl .exe obviously
 
"obviously"
 
That's what the $ is for, to make sure to only catch the extension
 
I didn't know if it was an error, or intentional
 
2:22 PM
I can't get over how horrid F# looks and reads.
 
it is still better than haskell
 
at the end (way after submission deadline) I have done the 3rd problem in Google Code Jam also in F#
 
What's wrong with F#? I've never really touched it.
 
IMHO nothing
 
In theory, it's an amazing, amazing language.
I just can't get used to it.
 
2:47 PM
it is indent based
 
I have no problem with that. In fact I like that the last line of the "block" is the return value. No return keyword needed. Like Scala
 
you will love Kodian (Wietlang)
there was some doubt about doing it, because of early returns such as guards but whatever
 
early returns are nice to have. F# struggles with that too. Writing computation expressions for that is not easy to read or use
 
3:11 PM
the only thing I still really dont like are exceptions
currently, I just have exceptions like how C# works
what I want is exceptions how Java's checked exceptions work (except not being an idiot) and combine that with Result<T> possibilities
but the problem is polymorphism
the root interface has to define a superset of the exceptions that the implementations can throw
so, if I just mark everything as "can throw any exception" the problem is solved, but then it is meaningless
 
3:32 PM
C#'s exception handling is good. If you have a knowledge about all possible exception handling places, than it's not really an exception. You can use error codes, if/switch statments, etc. to cover everything. For that in F# you have the railway programming.
even the author later warns that it shouldn't be used to reinvent exceptions
if you don't have control about the consumers of the exception, why should they bind theirself to your list of possible exceptions thrown...
your abort errors shouldn't be everywhere like flagging everywhere, that an out of memory is possible
Domain error/Panic/Infrastructure error separation is quiet good to understand
 
!~>new int[int.MaxValue]
-!!>Exception of type 'System.OutOfMemoryException' was thrown.
 
 
the door lock looks nice
 
How does mcr.microsoft.com/dotnet/core/sdk:3.1 not support C#8 ?!
 
minimal, simplify, single color
!~>((string)null) ?? throw new System.Exception("ironman")
-!!>ironman
 
 
2 hours later…
5:55 PM
@ntohl that depends
a simple example is int division
function divide(base: Integer, divisor: Integer) -> Integer {
    base / divisor
}
in simple terms, this is the implementation
but what happens when you divide by 0?
this example is often given about honest functions
in the example, this function is dishonest about what it can do
because it will not always work for all input, depending on the input, you might get a DivideByZeroException
so, in the case of checked exceptions, the function would be this
function divide(base: Integer, divisor: Integer) -> Integer throws DivideByZeroException {
    if(divisor == 0)
        throw DivideByZeroException("you doofus!")
    base / divisor
}
or, if you use Result<T>, then it would be
function divide(base: Integer, divisor: Integer) -> Result<Integer> { ... }
these functions are honest about their behavior
the problem I have with results is that the caller immediately has to deal with the different cases
value x: Integer = divide(a, b)
doesnt work any more, because it isnt guaranteed to be an integer and you immediately have to wrap the code below it in something like a map function
in the case of checked exceptions, if done nicely, the calling function just inherits the thrown exception declaration
(keeping in mind that the throws part can be implied from the context)
if you want to get it as a Result, Kodian uses a try function
it doesnt have a regular try catch finally mechanism that you might be familiar to
what it has is
function try(supplier: () -> T) -> Result<T>
then you can do
value x: Result<Integer> = try { divide(1, 0) }
and the Result<T> type has some functions that you would use instead of catches or finally
this way, you dont have to immediately handle the exception, but the code is still aware of the exceptions happening
for the case of an OOM error, I have to credit Java
OOM is not an exception by behavior, but an error by capabilities of the runtime
Java separates both of these Throwables into the categories Exception and Error
Errors cannot be checked, because they do not happen at a specific place
so, Errors such as StackOverflowError, OutOfMemoryError, etc would still remain just implicit
what I am currently working on is something that would help avoid dead code tho
and I guess the divide by zero example also works as a good example for that feature
they are data contracts
for example, the compiler would look at that implementation of the divide function
function divide(base: Integer, divisor: Integer) -> Integer throws DivideByZeroException
and it would apply a contract of "if divisor == 0, then Exception, else Integer"
in the call site, if you have code like
if(b > 0)
    x = divide(a, b)
the data contract would recognize that the exception case is excluded from the possible code paths
and it would completely disregard that from the type checking
x would then definitely be an integer
and the function that contains this code would not inherit the throws DivideByZeroException
 
6:16 PM
Hey all, We developed an a .NET Core Web API application using the following technologies:

-NET Core (3.1)

-Visual Studio 2019

Unfortunately, we have to deploy said application to the following environment:

-32-bit Environment

-Windows Server 2008 R2 Enterprise (Service Pack 1)

-IIS Version 7.5

-8 GB RAM
I had to reconfigure a lot of the setting for the .NET Core application project to use 32-bit(x86) setting values
I also installed Net Core 3.1 x86 sdk version on my development computer
Should I remove the directory path to the normal 64-bit dotnet from the Environment Variables Path within Windows?
 
6:33 PM
@crazyTech I think the first match in PATH will be used, so a CLI call to dotnet would use the x64 version as you have it. You could delete or move the order. I didn't think netcore3 worked on such old systems.
 
ok, I'll try change the order
 
hello i have list in C# that contains 4 million records
each record has 2 column ,
how can i insert them into mysql table
what is the most efficient way ?
 
Streaming a list into SQL is not as easy as streaming one out. You may be best off looping over a single row INSERT command. I am mainly familiar with MS SQL, where you can use table-valued parameters to do batch updates. I think other versions don't have something equivalent. If you are okay with concatenating SQL code together in C#, you could try doing batches with statements like...
"INSERT INTO MyTable (x, y) VALUES " + string.Join(", ", myBigList.Take(100).Select(obj => $"({obj.x}, {obj.y})"))
Definitely make sure you only open one SQL connection, rather than opening a new connection per request to SQL
 
7:37 PM
@Wietlol looks like the compiler have a lot of things to do. Like a recursive function, where b decreses each iteration, and the exit condition is once > 0 other time > -1
If b comes from input it's easier to decide
 
ofcourse, the compiler might fail to detect an intended contract
but it is a bonus in the first place
 
 
2 hours later…
9:25 PM
Hey all, what type of solution do you think makes sense for this problem?
I have an object that is serializable. It is intended for users to see (readonly). I want to guarantee that the json file that was unmodified
One solution I can see is overriding the GetHashCode() function and ensuring all properties under this serialized type will be override the hashcode appropriately if they are reference types. If implemented correctly, will the int generated will be guaranteed unmodified, or a clever change of some properties will allow for the HashCode function to generate the same int since its limited by the size of int
I should add, I want to guarantee this behavior only when deserializing.
 
 
10:00 PM
HashCodes look to be out of the game
https://docs.microsoft.com/en-us/dotnet/api/system.object.gethashcode?redirectedfrom=MSDN&view=netcore-3.1#System_Object_GetHashCode

Also to add, a checksum sounds a bit better, but I may run into a similar problem
 
10:19 PM
So your problem is... what, you have a thing, and you want to track if it's been changed?
Like, you hand something to a caller, and they hand it back to you, and you want to see if they changed it?
 
10:32 PM
That's a way to think about it.
 
there's two kinda ways that make sense to me to go about it
- keep a copy and hand another one out. when they give you the thing back, compare the old thing to the new thing. your thing is serializable, so you can even compare the string the original thing serializes to to the thing the maybe-modified version serializes to
- modify your thing's setters so that it sets a wasModified (or "dirty") flag if they change anything on it. note that this can lead to things being marked modified even if they weren't actually changed (say, a field was changed from A to B and back to A)
 
The reason I bring serialization into the equation is that the unique state must persist outside of the runtime. During the time of retreival (deserialization), we want to make sure what were deserializing wasn't changed
 
Ah, so you want to serialize the thing out somewhere
 
Yeah
 
and then be assured, when you deserialize it, it hasn't changed
Sounds like the thing that you'd use a checksum for
So is the serialized thing modified by someone outside your control?
 
10:42 PM
I was thinking of storing a checksum of the state of the object, that checksum uniquely identifies the objects state (all of its properties). It would be possible to modify the checksum in the serialized object and change all of its properties, but that is fine.
 
Because if they can modify the thing, they can modify the checksum you saved with it
Yeah
Sounds like you want a checksum
Especially if you just want to guard against accidental or careless modification
Note that the checksum won't let you reconstruct the original state, only tell you that it's changed
 
they would have to then modify it in accordance to generate the state that the checksum represents i.e. a whole new object which im fine with
Yes exactly, just to tell me that its changed
 
Sounds like you have your answer.
 
Alright sounds good. Great to bounce ideas off and clarify requirements, thanks Grace.
 
Happy to help!
 
10:46 PM
+1 if I could :)
 

« first day (3511 days earlier)      last day (1444 days later) »