Carsillas
Carsillas
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
That's not a bad idea, I worry about how it will work with types outside the current assembly however
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
That could probably work, hmm
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
I mean like what syntax would trigger the source generator? If I write MyClass<ITestInterface> myVariable then I can't swap out the variable type since it's already in the source
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
Possibly, what would the generated type names be? How would I trigger it? I don't know if a source generator works well here
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
Which isn't too bad
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
I think I've established that the worst case scenario for me is using the generic method solution in the image
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
It will work yes but it's pretty stinky for users of the library to have to create a new class for every different kind of variable they want, as if generics don't exist Even if the only user of the library is me haha
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
Yeah that's what I was hoping to avoid sadly
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
That's why I think it's no more "cryptic" than just a regular generic, perhaps less so
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
No problem haha
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
I don't want it to work with types that only implement one of the types, for my case it needs to be assignable to all of the types for it to compile
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
The extensions you provided above satisfy the usual OneOf use case, not "AllOf" that I'm trying to create here
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
How so? I don't think that solves it at all?
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
I feel like it's a reasonable sacrifice to allow compile time enforcement of types, but I do think it's probably the case that a method like I posted in the image will suffice
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
I don't think it's obfuscation to require type safety at compile time
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
It will still work if I just make it so the generic must be a subclass of my network entity, just was hoping to be able to use interfaces as well
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
It's not a huge deal it's just inconsistent with my other API, but maybe it should be? Basically it's a networking library and I can have networked variables like int and string but I wanted a way to replicate references to the network entities themselves, so I planned on having a class that was generic in a way that you could specify the types of classes that were allowed in that property, but using just an interface breaks the serializer because it doesn't know about the network ID that exists on the network entity class
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
Was hoping that because properties are methods under the hood they could be defined as generic (in the IL)
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
I wonder of generating IL directly would support something like this, not that I'll go that route but I wonder if its a language limitation or the some other aspect
74 replies
CC#
Created by Carsillas on 3/1/2023 in #help
❔ AllOf<>? Something along the same lines as discriminated unions?
That's what I figured, unfortunate that it can't be done with a property, the example I posted in the image is probably as close I can get then
74 replies