« first day (3839 days earlier)      last day (1092 days later) » 
01:00 - 12:0012:00 - 23:00

1:45 AM
 
mr5
@sergiol proof?
@minTwin just start right away, and when you get stuck onto some problem, that's the best time to ask question here or in SO.
 
 
3 hours later…
5:16 AM
@mr5 yeah they generally release it in the corresponding year
 
mr5
5:57 AM
They failed at 2008 though
 
6:09 AM
posted on April 08, 2021 by Scott Hanselman

13 years ago I wrote a .NET 3.5 WPF application for my then 2 year old baby/toddler. Maybe he was 18 months. He was small. He now wants to drive. https://www.babysmash.com/ continues to be a thing, even today. Recently "Chris The Meme God" had a 20 million view TikTok featuring BabySmash...where he failed to mention the URL. Sigh. Anyway, the code has been up at http://github.com/shanselman/ba

 
 
2 hours later…
8:37 AM
proof?
string part = "Table: Table1";
var entry= part.Split(": ");
error CS1503: Argument 1: cannot convert from 'string' to 'char'
and happens also with:
var entry= part.Split(": ", 2, StringSplitOptions.None);
or
var entry= part.Split(": ", StringSplitOptions.None);
 
mr5
dotnetfiddle.net/si1n4n .NET Framework
@sergiol you're probably using netframework
why do these compilers have different implementation of String.Split()
 
9:19 AM
proof?
water proof?
public static string[] Split(this string s, params string[] t)
    => s.Split(t, StringSplitOptions.None);
"asd, qwe, zxc".Split(", ")
or
"asd, qwe, zxc".Split(',').Select(x=>x.Trim()).ToArray()
!~>"asd, qwe, zxc".Split(',').Select(x=>x.Trim()).ToArray()
!=>["asd","qwe","zxc"]
 
mr5
9:52 AM
izz time!
 
izz time for our IT to fucking solve my problem of my workstation randomly getting bluescreens and forgetting the fucking boot order again
 
mr5
does it boot on CMOS first?
 
Bluescreens?
You sending a print job or anything?
 
mr5
current progress of my app
 
@mr5 It boots on some windows default bootloader that obviously can't boot from the VeraCrypt-encrypted drive
 
mr5
9:57 AM
this took me 3 months
 
3 months!
 
mr5
yeah including the setup of web apis + auth server
 
@mr5 And all those months you didn't realize that force-including a special character just sucks?
 
Got a video link? to show off? :D
 
Where CorrectHorseBatteryStaple
 
mr5
9:58 AM
@Squirrelkiller what character?
 
A special character
In the password
At least one
 
mr5
@Squirrelkiller oh decrypt it on other computer
 
Quick question regarding CommandParamters...
 
Nah just gotta go into BIOS and correct the boot order so it uses the VeraCrypt bootloader again
 
<Button Content="Add Ingredient" Command="{Binding ShowOverlay}" CommandParameter="{x:Type vm:RecipeCreateNewViewModel}" />
I am passing a ViewModel to the CommandParamter..
and receiving it here:
public void Createoverlay(object o)
{
    OverlayViewModel.Content = o;
}
 
mr5
10:00 AM
I'm actually focused more on backend than the frontend of this. I am architecting this carefully
 
But this displays..
But if i change the to this:
public void Createoverlay(object o)
{
    OverlayViewModel.Content = new RecipeCreateNewViewModel();
}
It works
 
Cast the object to the actual type
 
mr5
WPF or Xamarin?
 
WPF
 
My guess is the GUI thinks it's an object and just calls ToString() on it or something
Could override ToString with "Its-a me, ToString!" and see if that displays
 
mr5
10:02 AM
In Xamarin, this would be CommandParameter="{x:Static vm:RecipeCreateNewViewModel}" to properly reference the local variable
 
vm:RecipeCreateNewViewModel' member is not valid because it does not have a qualifying type name.
 
mr5
afaik, in x:Type, you're suppose to supply its arg with x:String, x:Int32, x:blabla but maybe it's just for Xamarin
 
Xamarin be weird yo
WPF masterrace
 
Agreed
 
for now
 
mr5
10:04 AM
heh
WPF will get deprecated
 
Blazor hot reload incoming with .NET6
 
mr5
maybe try to store the vm:RecipeCreateNewViewModel on resource dictionary?
and reference it via key
 
November 2021 - Realising cross platform for both Desktop and Mobile.
 
Try the cast thing first?
 
!~>"asd, qwe, zxc".Split(",").Select(x=>x.Trim()).ToArray()
 
10:05 AM
<!>Argument 1: cannot convert from 'string' to 'char'
 
Not sure what you mean by cast
 
hmm...
 
public void Createoverlay(object o)
{
    OverlayViewModel.Content = (RecipeCreateNewViewModel)o;
}
 
@nyconing running .net framework or roslyn?
 
Although now that I see it, it seems stupid
 
10:06 AM
Yeah because I am passing a VM via the xaml :D
 
its B.A.S.I.C.
 
Na because you put it into some property anyway
 
@mr5 This worked
Cheers lads
 
mr5
ha
WPF copies Xamarin
 
Xamarin released in February 2013 ;)
WPF November 21, 2006 :D
 
mr5
10:12 AM
 
Nice use of inspect element mr
 
mr5
btw, Bezos is getting angry at me for not paying them $12 last month 😈
waiting for the FBI to get into my room
 
For Prime?
 
mr5
aws
 
How?...
 
10:14 AM
FBI not in interest on money, but knowledge
 
@nyconing Well said
 
mr5
I could teach them how to define free tier
 
Unfortunately, their lawyers would just slap you with an english dictionary. Probably figuratively, but literally if they could.
 
no law inside FBI, they operates out of law
 
mr5
whtever happens, I won't pay them😈
this is just ugly
 
10:29 AM
Not sure I like it. Maybe just not used to it. Could be a nice way of initializing static and instance variables.
 
httpclient and their handler should be application-scoped singleton
or you facing leak, like japan
 
mr5
this one is from the demo though
but either way, I will let my DI decide if this goes to be singleton or transient
 
@mr5 Is this C# 9?
 
mr5
yep
is there anyway to statically/compile time get the MVC controller's full path?
 
Which path?
FQDN?
Output path of the dll?
Absolute path of the .cs file being compiled?
Route at which this controller's methods will be reachable?
 
mr5
10:45 AM
like this: domain.com**/path/to/controller/**
/path/to/controller/
^
 
Ah, the attribute on top of the controller provides that basically
 
mr5
but isn't that optional?
what if the dev didn't provide one?
I'm planning on ditching Refit for some architectural conflict
 
You can also map it in the startup, or maybe it's even enough to only state a route on each endpoint but I'm not sure if that works
What does refit do?
 
mr5
interface IProductRepository
{
    [Get("/api/product")]
    Task<List<ProductDto>> GetProducts(CancellationToken cancellationToken = default);

    [Get("/api/seller/{sellerId}/products")]
    Task<List<ProductDto>> GetProductsBySellerId(long sellerId, CancellationToken cancellationToken = default);

    [Post("/api/product")]
    Task<ProductDto> UploadProduct(ProductDto product, CancellationToken cancellationToken = default);

    [Delete("/api/product/{id}")]
    Task DeleteProduct(long id, CancellationToken cancellationToken = default);
basically this
it auto generates the implementations of this
 
Ah it created a restclient
Nice
 
mr5
10:49 AM
yeah
 
We use RestEase for that
 
mr5
it was copied from Retrofit in Java
 
Could put the route in a constant and share those constants between client and server
 
mr5
this ?
Nah, I hate global constants
 
Yeah that's what we're using. Same feature though, so not sure what that could fix.
 
mr5
10:51 AM
hmm
 
Shared interface then?
The IProductRepository could be implemented by the controller and by Refit('s successor)
 
mr5
I want the REST client interface to comply to some rules
 
Like what?
 
mr5
like it should be a class rather than an interface
 
What kinda rule is that
 
mr5
10:52 AM
and a common interface would be shared by the webapi and the mobile app
 
Also what reason could there be
 
mr5
so it's always sync
 
...sync?
Like, not use async/await?
 
mr5
like, here are what's known globally. comply to this. and the compliers would be the mobile app and the web api
no
I mean by sync is that changes to what project will reflect to the rest
 
mr5
10:54 AM
like, if I change the path of the api, it will reflect on both the mobile side and the api side
 
Isn't that the point of a shared interface though?
 
mr5
yeah
that's what I am trying to do
unfortunately, with the setup of refit and the C# shortcomings, it isn't possible
 
Each app will just generate the object via Refit/RestEase/whatever, but the interface makes sure they all use the same routes and parametesr
@mr5 In general, everything is possible one way or another. We're turing complete after all.
Make a concrete use case though and I might have an idea
 
mr5
Apr 16 at 8:46, by mr5
[+] Shared
	- IProductProvider
[+] WebApi
	- ProductController : IProductProvider
[+] Mobile
	- ProductRepository : IProductProvider
Consider the project structure above
Shared would contain the main contract that WebApi and Mobile should comply with
My problem with WebApi is the varying return type. It either be ActionResult<T> or IActionResult, but it's manageable.
In Mobile, it maybe a similar issue.
Ideally, varying return types is manageable.
But my main dilemma is, I am using Refit to generate client web APIs which requires the target class to be an interface also
This is what I posted before
 
again, adapt
 
mr5
10:57 AM
what adapt
 
adapter pattern
dont try to enforce things on stuff that is managed by something or someone else
 
I'm afraid I forgot the following: Why use IActionResult or ActionResult<T> instead of the actual type?
 
create your own wrapper of it or use it as a wrapper for your things
 
mr5
@Squirrelkiller I think someone replied to you: so that it can return BadRequest(), etc...
 
Ah right
 
mr5
10:59 AM
@Wietlol can you share a little example
oh
I think I get you
but that would make another layer to the services I would generate from Refit
 
I shared a little example telepathically
true...
 
mr5
hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
 
but this layer is one that you have very little management for
 
How do you rename properties ?
Like a shortcut for all
 
adapters should be easy to create and maintain
 
11:02 AM
@LV98 F2
Or ctrl+R, R I think with ReSharper?
 
@Squirrelkiller ty
 
@LV98 I use [ctrl][r], but your keymap might be different... also your IDE might be different... also you might not even use an IDE
 
mr5
yeah looks like I was about to do it since I'm going to complement the REST client services with a caching mechanism/dao
haa! nice. why am I not looking into the bigger picture
next problem is naming things
oh
i
it isn't solve Y_Y
you tricked me with that adapter pattern
@Squirrelkiller ctrl+R,R is the default
 
if you didnt solve it by adding another layer of indirection, then you didnt do it right
or your problem is that you have too many layers of indirection
 
But definitely not exactly the right amount of indirection
 
mr5
11:06 AM
I just come to realize that it isn't going to solve the problem.
I want a shared policy between mobile app and web api
 
yes
and you achieve that by providing a common interface of your service
with models and everything
 
mr5
yeah
and refit requires an interface
 
@mr5 If you wanna enforce types but still issue HTTP-codes, you might have to make a middlware for that
 
what does refit do with that interface?
 
Same as RestEase
or RestEasy
or like ten others^^
 
mr5
11:09 AM
@Squirrelkiller not sure I understand. I basically want them to sync HTTP methods, expected response type, and the path.
 
what does RestEase or RestEasy do with the interface?
 
mr5
@Wietlol it's is strictly limited to an interface.
so an interface cannot comply to another interface
 
Builds a rest client providing these methods and adapting http calls from them
 
then use an interface
@mr5 why not?
 
mr5
if it can, how?
 
11:10 AM
extend the other interface?
 
mr5
23 mins ago, by mr5
interface IProductRepository
{
    [Get("/api/product")]
    Task<List<ProductDto>> GetProducts(CancellationToken cancellationToken = default);

    [Get("/api/seller/{sellerId}/products")]
    Task<List<ProductDto>> GetProductsBySellerId(long sellerId, CancellationToken cancellationToken = default);

    [Post("/api/product")]
    Task<ProductDto> UploadProduct(ProductDto product, CancellationToken cancellationToken = default);

    [Delete("/api/product/{id}")]
    Task DeleteProduct(long id, CancellationToken cancellationToken = default);
 
C# interactive says "it just works"
 
mr5
This is how refit parses the metadata of the webapi
that's just inheritance
I2 does not comply to anything
 
'course, it complies to I1
 
so, this interface... is... what?
looks fine to me
 
11:12 AM
Whatever object implements I2 has to comply with I1 too
 
ahhhhhhhhhhhh
im falling
 
There is a whole other problem though
 
phew that was close
 
first of all, what do you use Refit for? generating the client library?
 
On the one hand, you abstract away HTTP by generating the restclient
On the other hand, you still want to use http codes
How is that supposed to wok on the client?
With a restclient, you only call a C# method
what is supposed to happen with a 418? 403?
400?
 
mr5
11:15 AM
I didn't mention I need to comply to status codes
 
You did mention you want to use them though
 
mr5
all I need are the response type, path (maybe not), HTTP methods (maybe not), and the input types
 
I believe that was the reason why you use ActionResults
 
mr5
@Wietlol yes
 
is it the generated client library of the reading of what to generate that is wrong?
 
11:17 AM
So when the controller returns a BadRequest(), what is the client supposed to do?
 
mr5
it generates classes of those interfaces
 
7 mins ago, by Squirrelkiller
Builds a rest client providing these methods and adapting http calls from them
 
mr5
@Squirrelkiller it should throw
 
@mr5 Throw what?
Just an exception?
 
mr5
why.can't.i.make.you.guys.understand. Y_Y
 
11:17 AM
...is there a BadRequestException?
@mr5 I'm working on it
One step at a time
 
Squirrel understands, but he is 100 levels deeper in another problem
 
Always get the actual requirements straight before implementing shit
 
mr5
I'll try with code:
// Shared project
ISharedProductPolicy
{
    TOutput DoThis(TInput input)
}

// Mobile
IProductRepository : ISharedProductPolicy
{

}

// API
ProductController : ISharedProductPoliy
{

}
 
that other problem is why I just stopped generating client libraries....
 
@Wietlol I'm trying to go level by level lol
 
mr5
11:18 AM
problem only is from the mobile side
 
@Squirrelkiller then try harder, you are a few ahead :)
 
@mr5 The problem is that you write code before having all the requirements
 
@mr5 so you are not satisfied with the generated client library?
 
mr5
@Squirrelkiller I didn't. It's just for demo purpose.
That is why I am always stuck onto something before I write something
@Wietlol I am actually thinking of ditching it but I'm not sure about the benefit of rolling out my own.
I actually made several rest clients
 
that is why you should stick with it until you realize what the problem is
 
mr5
11:21 AM
it's just shit
 
also, it is shit because the http libraries in .net are shit
I should write a port of khttp for .net
 
mr5
// Mobile
IProductRepository : ISharedProductPolicy
{

}
since refit needs interface, I can't make this comply with the shared policy
refit needs to read the attributes
 
> is it the generated client library of the reading of what to generate that is wrong?
 
mr5
and interface1 : interface2 is just inheritance
no
the wrong is, refit should accept at least an abstract class
 
no
it is either one of the ones I mentioned
@mr5 consider this example
what does refit generate for you?
 
mr5
11:26 AM
the rest client
 
what does it generate, considering that example?
 
mr5
which example?
it generates classes
 
the one you were supposed to consider
39 mins ago, by mr5
interface IProductRepository
{
    [Get("/api/product")]
    Task<List<ProductDto>> GetProducts(CancellationToken cancellationToken = default);

    [Get("/api/seller/{sellerId}/products")]
    Task<List<ProductDto>> GetProductsBySellerId(long sellerId, CancellationToken cancellationToken = default);

    [Post("/api/product")]
    Task<ProductDto> UploadProduct(ProductDto product, CancellationToken cancellationToken = default);

    [Delete("/api/product/{id}")]
    Task DeleteProduct(long id, CancellationToken cancellationToken = default);
^ this example
 
mr5
ah
instead of defining it from there, it should be define under the shared project
 
should it though?
 
mr5
11:29 AM
yes
 
what is the difference?
 
mr5
so the the webapi and mobile will be in sync
the difference of doing that is, making an update to one project only will trigger a compilation error
 
what I would do is
1, create an interface in a shared project
2, create a server side implementation of said interface
3, (possibly) auto-generate a client version of said server side implementation
 
Solution: Don't use ActionResult
 
I dont see ActionResult though
 
11:32 AM
His controller returns those
It's the reason the controller can't just implement that interface over there
 
@mr5 so, step 2 would already fail?
 
mr5
// Shared project
ISharedProductPolicy
{
    Task<TOutput> DoThis(TInput input);
}

// Mobile                                    OUTPUT          INPUT
IProductRepository : ISharedProductPolicy<List<Product>, CancellationToken>
{
    // Should be
    Task<List<Product>> DoThis(CancellationToken cancellationToken)
}

// API                                           OUTPUT                   INPUT
ProductController : ISharedProductPoliy<ActionResult<List<Product>>, CancellationToken>
{
    Task<ActionResult<List<Product>>> DoThis(CancellationToken cancellationToken)
I was thinking of doing something like this.
Problem is on the mobile part
> 3, (possibly) auto-generate a client version of said server side implementation
what you're suggesting is I need to make my own refit version?
step 2 is fine
 
You need to remove every usage of ActionResults and get used to using C# without trying to use http codes
 
@mr5 this is a good idea... if you want function level separation, but you probably want service level separation
 
mr5
@Squirrelkiller I don't see why is that a problem?
 
11:38 AM
The generated rest client will convert every non-200 code to an exception anyway
 
so, if your interface contains the exact input/output models, you cannot use ActionResult
 
mr5
Is it going to be deprecated?
 
because your interface said that you dont use ActionResult
you return a List<Product> directly
 
Since you're trying to abstract away the HTTP, you can't at the same time hold on to HTTP with ActionResult
 
^
 
11:40 AM
My controller doesn't even know that http codes exist:
 
mr5
I mean, ActionResult would reside on the webapi only
 
Why though
 
mr5
I don't see why is that going to be a problem abstracting the HTTP?
 
I don't wanna go in circles dude
 
mr5
because ISharedProductPolicy<TOutput, TInput>
 
11:42 AM
You told me the only reason you use ActionResults is to have http codes
But then you want to generate the rest client, which would erase all http codes on the client anyway
 
mr5
In the end, I would like to achieve something like this:
// Mobile
ProductViewModel(ISharedProductPolicy productPolicy)
{

}
 
You can't elevate half your application to a higher level and keep the other one directly on HTTP without doing so manually
@mr5 Then get rid of ActionResults
Build your controller methods like they would be called from C#
 
mr5
no
ProductViewModel will reside on mobile project
 
Wan to get a Product? Return a Product.
 
mr5
mobile project does not reference webapi at all
 
11:44 AM
@mr5 So what
 
mr5
I will only reference the shared
 
Of course
Know what
1) Make controller return the actual types
2) It can now implement the interface
3) Rest client can now be generated by the clients
4) Everything is always in sync
I will now stop debating this, that up there is your solution if you want one.
 
Do you guys use ICollectionView or ObservableColllection to display data within your view? Bearing in mind you want to filter data
 
ObservableCollection on the ViewModel I think
Not sure how to do the filter though, never tried
 
@Squirrelkiller what is Result ?
 
mr5
11:48 AM
@Squirrelkiller yeah. I think whatever additional response layer the webapi will do does not concern the mobile project since I only need to rely on the shared policy
 
Most results on google suggest to me ICollectionView as it is able to use the filter.
 
@Wietlol Basically { bool Success; T Data; string? ErrorMessage; }
 
ah
so you dont do REST then
 
@LV98 No Idea how to work with that, maybe ObservableCollection provides an object implementing that?
@Wietlol I do not
 
and use http purely as transport protocol?
 
11:49 AM
Yep
 
I see
 
mr5
@Squirrelkiller sorry. I think I am also out of energy to explain things.
 
I even have a middleware converting any exceptions to Result.Negative
 
mr5
I still need to work on my communication skills
 
any particular reason to not just throw an exception and use the exception message as error message?
 
11:50 AM
@mr5 You need to work on your architectural skills
 
mr5
no.
yeah
but this one is legit
 
@Wietlol I put the whole exc.ToString() into the message for easier debugging. Exceptions aren't something the user is supposed to see.
 
@mr5 what you can do is, like Squirrelkiller and me, primarily focus on treating http (or anything else) as a transport protocol
this will mean that your http api is bodged and will probably be unusable on its own
but the client library would work smoof
 
mr5
so ditch out the shared policy I'm talking about?
 
ditch http details
always return 200 (OK)
 
mr5
11:53 AM
that is what I am assuming
I don't actually see why ActionResult is of concern here
 
either use a result type and also make that result type part of your interface
 
mr5
since its output is going to be serialized anyway
 
or, just throw an exception and on 500 (internal server error), your client also throws an exception
 
mr5
and actionresult does not add any layer to the actual result
if I do ActionResult<Product> the response is just Product actually
what I believe it does is for the middleware thing
 
what I usually do is treating, in my case, AWS Lambda as transport protocol (which uses http as their implementation), and let it handle the exceptions
 
mr5
11:55 AM
yeah, that's what I am doing too, basically, the generated code in my webapi does just that
 
for actual http exposed endpoints, I carefully craft a fully detailed http compliant wrapper around the normal service
and in that case, http frameworks (for the server) are usually just a pain to understand and often cant even do it properly
and http clients are just weird bodges anyway, so I just write my own clients
but then again, my http library is just amazingly simple
as opposed to... RestSharp or HttpClient from .net
 
mr5
wait wut
so you're telling me to roll everything my own libraries to deal with those stuffs?
 
01:00 - 12:0012:00 - 23:00

« first day (3839 days earlier)      last day (1092 days later) »