20,119 questions
0
votes
0
answers
80
views
How to register function delegate with interface that has a generic type?
I wanted to create a flexible MessageProcessor, depending on the SupplierType(= enum) and depending on which MessageProcessor comes out a different Message-object will be used.
The current situation ...
2
votes
1
answer
60
views
Sorting the file structure list (Ctrl+F12)
Pressing Ctrl+F12 displays the file structure with a list of all fields and methods. Is it possible to change the sorting of this list so that the fields are displayed first and then the methods?
The ...
0
votes
2
answers
680
views
iOS 26. The problem with displaying the UISplitViewController
In iOS 26, the UISplitViewController primary or detail ViewController is displayed in modal mode, which is not correct. How to remove it?
Code for my UISplitViewController subclass:
override func ...
-5
votes
2
answers
176
views
How to avoid heap allocation when calling interface methods on multiple struct types in a shared list [closed]
I'm writing a program that is very sensitive to garbage collection so I'm trying to avoid allocating to the heap after initialization.
In the example below, calling Run() will allocate to the heap ...
1
vote
2
answers
193
views
Generic interface inheritance
I've tried looking up more specifics on this online but haven't found much info on this topic. I'm reading about generic interfaces from the C# documentation and everything seems reasonable until I ...
1
vote
4
answers
100
views
How to check for interface inheritance when looping through a list?
I have a Blazor server-side app where I use DynamicComponent on a page to create and add components at runtime. To do this I have the following:
A set of interfaces:
public interface IGetData
{
...
1
vote
1
answer
89
views
Using generic interface for structs with pointer receivers that are passed by value in Go [duplicate]
I have a bunch of types that implements a Equal(other myType) method for comparison against other values of the same type.
These types are used as map values and I wish to compare map equality using ...
2
votes
3
answers
114
views
Why can I assign a Card[] to a variable typed as InterfaceCard[] in TypeScript?
// types.ts
export interface InterfaceCard {
value: number;
suit: string;
getName(): string;
}
export interface InterfacePlayer {
handCards: InterfaceCard[];
receiveCard(card: InterfaceCard)...
0
votes
0
answers
132
views
Directus custom button on the collection page extension
I'm trying to create a simple extension for Directus which adds a button at the header on collection list page (a button nearby "+" button)
When a user selects some of collection items, then ...
0
votes
0
answers
64
views
TS2339: (TS) Property 'roundRect' does not exist on type 'CanvasRenderingContext2D'
I am writing a TypeScript application in Visual Studio. However, when I try to use the roundRect method associated with the Canvas 2D API, I get the compilation error:
TS2339: (TS) Property '...
-1
votes
1
answer
137
views
Understand reflection usage with structs and interfaces
I try to understand the correct usage of reflection with a struct compose by nested structs that implement an interface on Golang;
Here the code:
package main
import (
"log"
"...
0
votes
2
answers
94
views
Interface calculated getters [duplicate]
Just getting in to interfaces and I can't seem to find how to implement calculated fields... I know I can do this in the deriving class, but is there a way to do this in the interface itself?
A very ...
2
votes
1
answer
91
views
Java Stream API: Incompatible types: List<ArrayList>> cannot be converted to List<List>
My intention was to replace the following snippet:
List<List<String>> lists;
for (int i = 0; i < n; i++)
lists.add(new ArrayList<String>());
with Stream API one-liner:
List&...
0
votes
0
answers
50
views
How to define schemas for FastAPI when a image is involved [duplicate]
I know the concept of schemas and how we use it when designing FastAPI applications. For example
from pydantic import BaseModel
class User(BaseModel):
username: str
email: str
age: int
...
1
vote
0
answers
75
views
Import interface/fuctions through WIT in JS Web Assembly Component Model WASM
I have a WIT compatible Web Assembly Component Model based module written in JAVASCRIPT/TYPESCRIPT and exposed as a WASM using jco and further transpiled to run in the browser. I have 2 questions in ...
0
votes
1
answer
90
views
How to extend typescript interface with specific values enforced in an array property
I have a basic interface, which I use down the line to enforce specific values on other interfaces:
interface ObjectWithEnforcedValues {
values: readonly EnforcedValue[];
}
enum EnforcedValue {
...
-1
votes
2
answers
36
views
Mocking external package struct that depends on HTTP request
I'm working on a terminal game based on this card game that gets its cards from deckofcardsapi.com. Cards are stored in a struct named Card in a package called card and each Card is stored in a struct ...
3
votes
0
answers
108
views
Wrong interface method called [duplicate]
Is the following a .NET 8 / C# bug?
internal class Program
{
interface IGetString
{
string GetString();
}
class A : IGetString
{
public string GetString() => &...
0
votes
3
answers
114
views
Generic method in non generic interface
Here is my interface.
public interface IFoo
{
TOut Process<TOut, TIn>(SomeClass<TOut, TIn> container)
where TOut : class,
where TIn : class;
}
I would like to achieve ...
2
votes
3
answers
111
views
Why no compile error at CustomerService service = ServiceFactory.getInstance().getServiceType(ServiceType.CUSTOMER);
SuperService:
package service;
public interface SuperService {
}
CustomerService:
package service.custom;
import dto.Customer;
import java.util.List;
public interface CustomerService{
boolean ...
1
vote
1
answer
80
views
How can I implement Interface for Node class
I'm trying to implement interface for Node class in CSharp.
NodeInterfaces.cs
public interface INode<T>
{
T Value { get; set; }
Node<T> Left { get; set; }
Node<T> Right { ...
1
vote
1
answer
76
views
Is there a language feature like Python's `issubclass` to cast instances of System.Type to the actual type (to access static methods w/o reflection)?
I have the following interface which contains a static method definition:
public interface IUpgradableDataSource
{
static abstract Task<JsonElement> UpgradeSourceConfigurationAsync(
...
1
vote
1
answer
61
views
Struct field with multiple const types
Say I have a const type and corresponding sub types -
type Animaltype int32
const (
dogs Animaltype = iota
cats
)
type dogtype int32
const (
retriever dogtype = iota
whippet
)...
3
votes
1
answer
84
views
Error when converting BehaviourSubjects in Angular
Let's assume we have two interfaces:
interface A {
name: string;
_id?: string;
}
interface B {
name: string;
_id: string;
}
When assigning them to each other, typescript behaves like I would ...
4
votes
1
answer
110
views
Why must an internal method of a public interface be implemented via a public method?
I have a public interface. One of its methods is marked internal. And it has to be - it takes an argument that is an internal type.
I write a public class that implements this interface, I do so via a ...