20,121 questions
1
vote
1
answer
101
views
Get all implementations of an interface for a class, including for base
public interface A<out T>
{
public T Property { get; }
}
public class BaseClass : A<string>, A<int>
{
string A<string>.Property => "BaseClass";
int A&...
Best practices
0
votes
1
replies
55
views
How to constrain an interface to be only applicable for slices or maps
I've got a Matcher interface in Go that is implemented by quite a lot of underlying types.
I'd like to restrict the Matcher interface such that implementing types can only be a "collection", ...
0
votes
0
answers
82
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 ...
1
vote
1
answer
60
views
Is there an eslint or tsconfig rule to disallow inline type import?
initializeForOrder: (params: import('./drivePhotosTypes').OrderActionParams) => Promise<void>;
getOrderState: (orderId: string) => import('./drivePhotosTypes').OrderPhotosState | null;
...
2
votes
1
answer
66
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
1
answer
88
views
How to handle incompatible versions of PHP interfaces?
I have a PHP application which uses the \Psr\Log\LoggerInterface interface and classes that implement that interface. My application can be configured to authenticate users against a Joomla ...
0
votes
2
answers
748
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 ...
1
vote
2
answers
99
views
golang interface matching different return types in generated code?
I have to deal with generated code - hence, it can not be changed.
func GeneratedCode(someArg string) (*GeneratedFirst, error) {
// code does something and returns,
// returning an empty ...
-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 ...
0
votes
1
answer
59
views
Is there any way to make Groovy 4.0.x compile interfaces with static methods?
I want to make an interface with some static methods for decorating instances or adapting them to other interfaces. However, Groovy 4.0.x gives an error when trying to do this, probably because it's ...
1
vote
2
answers
196
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 ...
0
votes
0
answers
98
views
ARM Cross-Trigger Interface
I have a question regarding debugging on a multi-core board.
On my board, I have multiple cores, and for each core, I have created a CTI (ARM Cross-Trigger Interface). I am able to run and halt each ...
1
vote
4
answers
101
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
51
views
Using Kotlin Generics in Nested Interfaces
I'm trying to write an interface for sending generic events to a remote server, along with a listener which returns a response that includes the list of events that was sent/attempted to be sent.
...
1
vote
1
answer
91
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 ...
1
vote
0
answers
73
views
Nominal typing with C++20 concepts [duplicate]
I'm trying to replace virtual base classes with concepts in a few places in my codebase where dynamic polymorphism isn't actually being used. However I still want it to be nominally typed. In ...
2
votes
3
answers
117
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
50
views
Docker running on OpenSUSE Leap 15.6
I am running Docker on my OpenSUSE Leap machine (in order to publish a web page in WordPress) which also serves as a firewall. How do I get my container to communicate on both the external interface ...
0
votes
0
answers
139
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 ...
1
vote
2
answers
159
views
C# interface static method not always resolving correctly to derived class
The example below is contrived/simplified but displays the issue I am seeing.
Interface with a static method.
Base class that implements interface.
Two derived classes. One implicitly implements ...
0
votes
0
answers
65
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 '...
4
votes
1
answer
145
views
Go GC doesn't collect dead weak pointers
I am trying to use weak pointers introduced in go1.24 to build a system in which weak pointers can be passed as interfaces. The problem is that weak.Pointer doesn't follow the same interface as the ...
-1
votes
1
answer
146
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"
"...
-1
votes
1
answer
79
views
Is IEnumerable.GetEnumerator() an acceptable name for an interface method implementation on the interface IEnumerable? [duplicate]
I stumbled across this definition:
using System.Collections;
namespace LanguageFeatures.Models
{
public class ShoppingCart : IEnumerable<Product?>
{
public IEnumerable<...
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 ...
5
votes
2
answers
174
views
Simpler forwarding of contained object
I have a proprietary file format definition that contains a header format:
class Header
{
public:
uint32_t checksum;
uint16_t impedance;
uint16_t type_of_data;
uint32_t ...
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&...
1
vote
2
answers
135
views
How to properly implement instantiation of an abstract class based on parameters
I want to create a class that is called from other methods and change the implementation of that class based on some context (like params):
Abstract class:
class PdfRenderer(ABC):
# Something else ...
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
2
answers
98
views
C++ template class as a member in a normal class
I'm creating GPIO abstraction driver for stm32. There should be a class with register accesses and another class that holds a reference to it. In that way the class holding a reference has no idea ...
1
vote
0
answers
76
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
0
answers
53
views
Left sidebar database tree missing tables
I recently used phpmyadmin interface to duplicate a table from xxx_terms to aaa_terms. After doing this, the xxx_terms table disappeared from the db/table tree display on the left side of the window. ...
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 {
...
0
votes
0
answers
35
views
Call generic interface with generic argument without explict specifing both T [duplicate]
I need a way to store objects that have method with same return type, but different arguments types and call them without much extra code. My basic concept is:
public interface IBase
{
}
public ...
-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 ...
-2
votes
1
answer
72
views
How to correctly extend an interface when using void
I have these TypeScript interfaces, and i want to extend HandleSendMessage with HandleMessage, but the void makes it a problem.
The project is in React.js with TypeScript and Vite, and it's part of ...
3
votes
0
answers
109
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
2
answers
91
views
Is there a way to get Java to recognize a higher order interface when a lower order is initialized? [duplicate]
I have one overarching interface then a bunch of different child interfaces
public interface Parent {
String foo(String s);
}
public interface ChildA extends Parents{
default String foo(String s) ...
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 ...
4
votes
2
answers
279
views
Java example: Why can a function in this w3schools example run when it is not defined?
Here is the issue, you can find it in w3schools lamda expressions chapter last example:
interface StringFunction {
String run(String str);
}
And:
public class Main {
public static void main(...
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 ...
0
votes
0
answers
21
views
interface for model and general in ts
I am stuck in a situation please help.
I created a interface for User Model in mongoose and ts. the model has profile pic field which consists of a reference to document model. so my user schema model ...
1
vote
1
answer
84
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
58
views
Flutter/Dart- DAO interfaces- can't overload method parameters
Wanted to create an interface for DAOs that can be "overloaded" with different method params types:
abstract class DaoInterface {
Future<List<Object?>> findAll();
Future<...
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(
...
3
votes
3
answers
216
views
In C++, is there a way to provide object member name as template parameter?
I have multiple classes C1, C2, etc, each has different members variables, ex: C1M1, C1M2, C2N1, C2N2. And I have a pointer to data that could be an object of C1, C2 based on initial bytes.
Is there a ...
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
)...
0
votes
1
answer
182
views
Problem with method visibility in a trait in Rust [closed]
I'm working on a Rust project and have a trait called Auth with an asynchronous method auth_login. The issue I'm facing is that when I try to make the method accessible from other modules using pub, I ...
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 ...
1
vote
1
answer
26
views
How to specify the interface from which an object comes from in idris
Say I have the following interface in idris:
interface I a b where
x : a
y : b
And then I try to define the following function:
x' : I a b => a
x' = x
But then I get this error:
Error: While ...