« first day (3705 days earlier)      last day (1243 days later) » 
01:00 - 13:0013:00 - 00:00

1:27 AM
@mr5 Content farmer site, it wastes reader time, earn money by ads. Normally had sensational headline and targeted contents
 
mr5
Can't blame them as long as people keep investing on that company.
 
 
5 hours later…
6:23 AM
@IROEGBU Make implicit operators to automatically convert from and to string.
Also good morning
 
Whole world: deserialize
PHP: unserialize
 
7:26 AM
[Squirrel in Training] GoOoOoOoOoOoOoOoOoOoOoOd Mornin' pleberinos!
 
8:15 AM
@Squirrelkiller ew, no
 
He wanted to make status equal to the value property - this is the way to most seamlessly do that.
 
8:37 AM
the way to most seamlessly do that is to make them the same property
introducing implicit operators should make you feel bad
except when they are appropriate, but then C# wont allow you to do that
 
9:07 AM
@Squirrelkiller Yeah, I'm leaning to towards this... I went with strings for now though, but using implicit and explicit operators look neater.
 
[Squirrel in Training] is nice to have
[Squirrel in Training] but beware iroe
[Squirrel in Training] you colleagues might burn you as a witch if you use implicit operators.
[Squirrel in Training] I feel like only 20% of .net devs know about that feature
 
I take it similar to dynamic - only 20% of .net devs want to know about it.
 
and 95% of those 20% only want to know about it so they can avoid it
 
And the other 5% haven't used it yet
I think the only case I use an implicit operator for currently is to map a db model to a business model, because they have literally the same properties.
Cap'n o7
 
that works... until the db model starts to change
 
9:16 AM
Which is the point when I'll make it an extension method instead. But until then, it's implicit.
 
[Squirrel in Training] I use it for returning Result<Data>
[Squirrel in Training] Where Result has somehting like WasSuccessfull ErrorMessage
 
I want it for IOptional, but C# wont allow me
 
[Captain Obvious] I am not in the 20%
[Captain Obvious] Wiet c# is just protecting you from doing something stupid
 
it is not stupid
it is like Nullable<Boolean> b = true;
instead of Nullable<Boolean> b = new Nullable<Boolean>(true);
in this case, implicit operators make perfect sense
(but for IOptional instead of Nullable)
the problem is that C# wont allow implicit operators to be used for interfaces
 
How would you like this implicit operator to behave?
 
9:22 AM
but classes are not allowed to have variance in generics
so... decisions
I currently have a static method Optional.Of(x)
 
@Squirrelintraining How does the operator decide whether the result conveys success or failure? If you put a string, is it successful?
 
which takes a T and returns an instance of IOptional<T>
 
@Wietlol What does this method look like specifically? Just new Optional<T>(x);?
 
public static IOptional<T> Of<T>(T value) =>
    value == null
        ? (IOptional<T>) new EmptyOptional<T>()
        : new ValueOptional<T>(value);
there are 2 direct implementations of IOptional<T>, one with a value and one without
then there is a sub interface IResult<T> with its own implementations
 
Is Optional a static class or something? Just for this purpose of constructing the implementations?
 
9:35 AM
Optional is a utility class with some static methods and some extension methods
 
Just use that one then
I tried to make an MCVE
	public interface IOptional<out T>
	{
		T Value { get; }
	}

	public abstract class Optional<T> : IOptional<T>
	{
		public abstract T Value { get; }

		public static implicit operator Optional<T>(T value)
		=>
			value == null
				? (Optional<T>)new EmptyOptional<T>()
				: new ValueOptional<T>(value);
	}

	public class EmptyOptional<T> : Optional<T>
	{
		public override T Value { get; } = default;
	}

	public class ValueOptional<T> : Optional<T>
	{
		public ValueOptional(T value)
		{
			Value = value;
 
[mr5] How is Nullable/Optional different from T?
 
T is a generic. Nullable/Optional makes something explicitly optional. The two are kinda hard to compare as they have totally different concepts.
 
mr5
Botler didn't capture my edit. It's supposed to be T?
 
@Wietlol Would have to scrap the interface though, as it is now redundant
 
9:43 AM
nope
 
@mr5 T? in C# could be two things: Either Nullable<T> for structs or a nullable reference type.
 
@mr5 T? is trash tho
 
I wonder what VS has to say to that...
 
@Squirrelkiller interfaces can be IOptional<out T>
 
Well your interfaces are now abstract classes
Oh wait you actually use multi inheritance here dont you
 
9:45 AM
no multiple inheritance
but polymorphism
they are opposite
 
In that case, you can make all your optional interfaces abstract classes
 
true...
maybe...
 
No, optional
 
nope, abstract classes still wont allow <out T>
> Variant type parameters could be declared in interfaces or delegates only
 
Well, you could still not scrap the interface to use <out T>
It's actually in my MCVE lol
 
9:49 AM
not scrap the interfaces?
what advantage would that give me?
 
<out T>, although I'm not aware of the use case right now as I'm only here with one half of my brain as hte other half is attending a lecture
 
IOptional<Object> stuff = (IOptional<String>) FindString();
similar to
IEnumerable<Object> stuff = (IEnumerable<String>) FindStrings();
these are allowed if you have <out T>
considering the responsibility of the monad, this is perfectly fine behavior
 
mr5
LINQs are example monads right?
 
IEnumerable<T> is a monad
 
mr5
10:05 AM
ehh
 
monads are basically types that have a few specific functions
 
[Captain Obvious] It sounds like you're looking for nullable?
 
public Self<R> Map<R>(Func<T, R> mapper)
public Self<R> FlatMap<R>(Func<T, Self<R>> mapper)
are two of the ones I can remember :D
but those are the most important ones
@CaptainObvious except that nullable is pretty bad
 
tbh, what I have now is also having about 100 methods just to work properly with generics and async...
 
10:08 AM
[Captain Obvious] Why are you so bad at c#
 
but that is mostly generics and async's fault
C# is just bad at programming
 
[Captain Obvious] Generics are easy
[Captain Obvious] Async is easy
 
Task<T> is invariant
Task<Object> myObject = (Task<String>) GetStringAsync();
that is illegal
because Strings are not Objects in async world
 
[Captain Obvious] Well duh
 
why duh?
Task<out T> makes perfect sense
 
10:10 AM
[Captain Obvious] Because Task<x> != Task<Y>
 
but no no no, Task is a class and classes cannot be variant, because of stupid design
yet IEnumerable<Object> myObjects = (IEnumerable<String>) GetStrings(); is perfectly fine
 
Task<object> would be totally fine returning a POCO
IMO
 
[Captain Obvious] Why would you even want to return Task<Object> anywya
[Captain Obvious] That's so retarded
 
I dont
 
[Captain Obvious] So then it's a non issue
 
10:12 AM
but because Task<T> is invariant, I cannot return Task<IOptional<T>>
 
[Captain Obvious] Why not
 
because IOptional<out T>
 
[Captain Obvious] You could just stop using generics wrong
[Captain Obvious] Something something XY
 
mr5
Does Kotlin permits what you are trying to accomplish?
 
10:13 AM
I havent tried...
Kotlin has acceptable nullables
and I have never used async in kotlin yet
 
[Captain Obvious] Wtf is this IOptional anyway
 
but kotlin does allow class MyClass<out T>
it is an acceptable Nullable for classes
and older than C# 8
and written by myself
and a private library
 
o]/
 
oi
 
!~shiba
 
:o
 
[Captain Obvious] What you're saying
[Captain Obvious] Is you wrote something stupid and now you're complaining it doesn't work
 
I wrote something perfectly fine and it works like a charm
but C# wont allow it to become better
because of stupid design choices
 
[Captain Obvious] "Stupid design choice"
[Captain Obvious] in your opiniion
 
mr5
What's the fix? Change the signature to Task<out T>?
 
10:21 AM
sure...
that would help a lot with the async interop
 
[Captain Obvious] Because clearly nobody else had a problem with it as the general shape of Nullable<T> has been in place for 15 years with no problem
 
@CaptainObvious I think many people can agree with that it is stupid that implicit operators only work for classes and structs
 
As Task uses T as an output, Task<out T> would only be logical.
 
oh, System.Nullable is perfectly fine... lacking a bit of interesting API, but it works fine
C#8 nullable is trash tho
 
[Captain Obvious] With some minor tweaks about 11 years ago
 
10:23 AM
C#8 nullable is just more powerful static analysis lol
 
[Captain Obvious] 8 years ago*
 
@Botler Shame there isn't a feature to edit your messages afterwards?
 
[Captain Obvious] Yeah it's awkward to implement
 
C#8 nullable breaks quite a bit of stuff tho
 
[Captain Obvious] Gotta keep track of the discord message IDs AND the stack message IDs
[Captain Obvious] So when one updates the other can be updated without sending a duplicate message, which is what currently happens when Stack messages are edited
[Captain Obvious] The worst part is the stack message event data doesn't even say it's an edit, it's just "it's a message lol"
 
10:26 AM
it does say it is an edit
 
Editing via http is POST https://chat.stackoverflow.com/messages/51099024 { text: $editedText, fkey: $keyFromLoginCookie }
 
and if you finally try to use Wietbot's events, you even get the previous events of the same message
 
[Captain Obvious] Not in SharpExchange
 
all in one block
SharpExchange might be silly then
 
[Captain Obvious] or whatever the liubrary is called
[Captain Obvious] Yeah it is
 
10:26 AM
Wietbot publishes an event list
 
[Captain Obvious] @squirrelkiller you wrote this garbage you know what it's like
 
@Botler I never touched the discord stuff, no idea how relaying works lol
 
{
    messageId: 1234567890,
    events: [
		{
			eventId: 1234567890,
			messageId: 1234567890,
			type: "message-posted",
			timestamp: 1234567890,
			sender: {...},
			content: {...}
		}
		{
			eventId: 1234567890,
			messageId: 1234567890,
			type: "message-edited",
			timestamp: 1234567890,
			sender: {...},
			content: {...}
		}
		{
			eventId: 1234567890,
			messageId: 1234567890,
			type: "message-deleted",
			timestamp: 1234567890,
			sender: {...}
		}
	]
}
something like this
 
[Captain Obvious] Yeha but you know how much AIDS the sharpExchange lib is
 
except not json
 
10:28 AM
[Captain Obvious] "except not json"
[Captain Obvious] wtf is it then
 
binary
 
The architecture is modular though so you could make the edit command specifically use http directly
 
[Captain Obvious] ew what the fuck
 
it is polymorphic, type safe, cross platform, and really fast
and compact
 
mr5
I think I've encountered what Wietlol is suggesting here. I just can't explain it very clearly lol.
 
10:29 AM
[Captain Obvious] I mean I know that things like protobuf are fast af
 
also is supposed to allow dynamic parsing, but I didnt add that in the C# library
 
[Captain Obvious] But it only really matters when your application is fasty
 
I still want the type safety and polymorphism tho
keeping in mind, the content is a platform independent format
it is already parsed
it is an object tree with stuff
I dont want to parse json for that
 
[Captain Obvious] What do you mean it's type safe
[Captain Obvious] It's serialised data
 
and I cannot include the type names/paths or whatever because that would be platform specific
it is type safe as in the serialized data knows its own runtime types
 
10:32 AM
[Captain Obvious] But you just said you can't include the type names
 
var obj = schema.Deserialize<Object>(data);
AssertTrue(obj is MessageEventList);
 
[Captain Obvious] Why not just Deserialize<MessageEventList>
 
ye, I cant include the type names, so I need a different approach, one that JSON doesnt simply support
you can do Deserialize<MessageEventList> obviously
but what about...
Deserialize<IMessageEvent> ?
 
[Captain Obvious] What about it
 
it could be a MessagePostedEvent, MessageEditedEvent or MessageDeletedEvent
the data knows what it is, the schema will map it to the runtime
 
10:34 AM
[Captain Obvious] But if it's "paltform independent" etc
[Captain Obvious] What if the platform doesnt have one of those types
 
then you are probably missing the library with the models that you want to deserialize
in that case, it goes back to dynamic loading
so
 
[Captain Obvious] So it may as well be json then
 
var obj = schema.Deserialize<Object>();
AssertTrue(obj is BitDynamicObject);
the dynamic object still knows that it is of a specific type, different than the other types of message events
it just doesnt have a class to represent it
if you literally provide no runtime information, then it is just a number
if you provide the .bitmodel file, it will give you names as strings
 
[Captain Obvious] So an enum
 
if you provide the .bitschema file and have the library with the models, it will give you the data in instances of those classes
enum could be...
except that you dont know which values there could be at compile time
keeping in mind you are literally just dynamically loading all the shit
the C# library is still missing features tho
 
10:38 AM
[Captain Obvious] I'm still not understanding the advantages
[Captain Obvious] Aside from speed
 
the advantage is to not have to bother with how to parse the data
 
[Captain Obvious] I haven't tried it like, Json is fine for me
[Captain Obvious] I mean parsing data is easy
 
mr5
@Wietlol this is highly unlikely to work for known systems. What if they have different architecture where sizeof(char) == 1 or sizeof(bool) == 32? Even when you serialize in byte array level, how could it possibly know that it's T1 and not T2 where sizeof(T1) == sizeof(T2)?
 
my web services still use json, and I use json schemas to validate them and then parse the data before I use it
 
10:40 AM
but for internal services, I dont do that
keep in mind, Wietbot alone has 60 independent services
 
[Captain Obvious] I just do that then all my json problems are solved
[Captain Obvious] Simples
 
each having to communicate over the network
 
[Captain Obvious] My misc json is now an actual type
 
I wanted an easier and safer solution than json
"I just do that" I think your message didnt get through
 
10:41 AM
@mr5 the schema/serializer knows how to parse the bytes
for example, a boolean has 2 possible states
if language X provides a type to represent that, I will use that type
if language X has Boolean but it is actually for 3 possible states, I will have to introduce a BinaryBoolean or something like that
the schema/serializer also takes care of how it is serialized
for example, Java's int to binary default is low endian (or high endian) and C#'s is the opposite
the library chose one over the other (for no particular reason) and makes sure everyone reads in the same way
 
text is stored in UTF-8 by default (can be specified otherwise, but havent had the need yet) and if language X does not support that, I would have to write my own UTF-8 parser
 
[Captain Obvious] There's always the less ambiguous true and false which are fairly hard to fuck up
 
it would be a pain, but it would eventually work
@CaptainObvious most languages indeed do have a built-in type for binary booleans
 
[Captain Obvious] If the Json was too verbose maybe it would be a problem, but I don't see a problem
 
10:45 AM
there is a problem when the object you are deserializing too uses polymorphism
for example
public class MessageEventList
{
    public IList<IMessageEvent> Events { get; set; }
}
public interface IMessageEvent { }
public class MessagePostedEvent : IMessageEvent { }
public class MessageEditedEvent : IMessageEvent { }
public class MessageDeletedEvent : IMessageEvent { }
now try to deserialize a MessageEventList
Json will say "ooh, I found a list of objects... I wonder which implementation of the interface they were..."
now it börks
and you have to jump through hoops to make it work with polymorphism
"oh but that is simple, you just include the type name of the actual type"
ye... now it is .net dependent
or you can include a more abstract information field for the type
now you have to figure out how to parse it so it understands that the type field contains that information and map it to each type
I prefer a tool that I can just trust that it serializes and deserializes without error
without additional configuration
without additional work
 
[Captain Obvious] You could just not make a list of unpredictable objects
 
ye... no
same for the message content
the content is a tree of content parts
 
[Captain Obvious] A message can only be posted once
[Captain Obvious] And deleted
 
some messages start with different formatting than they end with
this would be...
{
	parts: [
		{
			text: "some messages"
		},
		{
			text: " start with"
		},
		{
			text: " different formatting"
		},
		{
			text: " than they end"
		},
		{
			text: "with"
		}
	]
}
now... obviously, it is missing the type information
because I cant be arsed
I just have a library that can parse the binary and get me runtime instances representing the parts through the type system
 
11:10 AM
[Captain Obvious] See this is what we were saying about you not fucking with the message
[Captain Obvious] That's not even slightly helpful
[Captain Obvious] That and
[Captain Obvious] You know
[Captain Obvious] You're a black box
 
11:32 AM
obviously.

The default assumption is that it worked.
i.e. Result<Address> GetAddressFromPerson(int personId)
{
   if(!PersonExists(personId) return Result.FromFailure("Sorry couldnt find the vbloke");

   retrun getaddressInternal(personId);
}
Please giff respecc for my semi sudo code wörk
 
it is perfectly helpful
with this, you can easily write a formatter for discord
and you only have to parse the discord message into this
you dont have to figure out how stack overflow formats their messages, you just get a description of the message itself
if you dont want a formatter and just want the text, you can just use the GetSimpleText() method
although, that would remove most of the useful things
I could write the discord parser and formatter as well and include it in the library...
 
I'm using asp.net core and I'm a n0ob...everything I see says that the ~ used in a path represents the 'Application root' but I see different behavior depending.

<img src="~/images/test.png" />

Compared to:
@await Html.PartialAsync("~/Pages/Shared/_Test.cshtml")

Seem to work totally differently. The first one seems to treat ~ as my /My_Project/wwwroot folder (inside Solution Explorer) while the second one treats ~ as as my /My_Project

Can someone confirm if my understanding is correct?
 
11:48 AM
Hi anyone help me on powershell
here
 
11:59 AM
What is the question
 
mr5
@RobP. it still points to the same root path, it will differ depends on when you are calling this. It resolves the relative path from root. Basically, you're just querying where you are from the relative to the root path, or it just works the same as pwd/cwd/cd CLI command
 
12:19 PM
I'm not sure I follow. My folders look like this:

/MyProject
..../Pages
......../Shared
............_Test.cshtml
..../wwwroot
......../images
............test.png

If /MyProject is the root then shouldn't ~/images/test.png fail because it doesn't include wwwroot? And if /MyProject/wwwroot is the root, then shouldn't ~Pages/Shared/_Test.cshtml fail because there is no Pages subfolder under wwwroot?

I do apologize, I feel like I'm just not getting it, but I really appreciate the response
 
[mr5] shame. edits. shame.
 
~ sorta does 2 things
 
mr5
Routing also plays in this regard. Most of server frameworks I think disregards the wwwroot
 
$csvTable = new-object “System.Data.DataTable”
value1=[int]$csvTable.Rows[10].Column1
 
It's context dependent. It's more like "relative to the site root when it's compiled"
 
12:22 PM
value1 is coming as null
like I want to fetch last row first column value
 
ie when compiled, wwwroot IS the site root
kinda
 
mr5
If you code in nodejs, it will clear things up for you.
idk where asp does its internal routing.
 
any idea why null ?
 
It's magic, don't worrya bout it
Maybe because you haven't created and rows or columns
You can't just create a new table and then go "I want the 10th row"
 
Its there
even if I make 0th row
it is null
 
12:25 PM
You also need to make columns
 
But I have data in table
 
No you don'ty
You just created a table
 
I am getting values from the db
 
It has nothing in it
 
hence there are columns as well
 
12:26 PM
Well if you are then you're skipping loads of code
So either show us it all or we aren't going to help
 
Haha - thanks @CaptainObvious / @mr5

That helps. This is the sort of thing that just works and I've never done much asp.net so I accepted it without much consideration
 
Write-Output $MasterDatabaseCommand.CommandText

Write-Output 'End'


$csvResult = $MasterDatabaseCommand.ExecuteReader()
Write-Output 'dummy1'
Write-Output $MasterDatabaseCommand.CommandText
$csvTable = new-object “System.Data.DataTable”
Write-Output 'dummy2'
$csvTable.Load($csvResult)
This is th code
$lastestValue =[int]$csvTable.Rows[10].Column1
latestvalue is coming null
 
So that's a bit more helpful
But as I don't work with databases directly I can't help lol
 
rofl
 
[Squirrel in Training] Killerino didn't giff respecc :<
 
mr5
12:38 PM
xD
mybe that 11th row doesn't exist?
 
01:00 - 13:0013:00 - 00:00

« first day (3705 days earlier)      last day (1243 days later) »