Skip to content

Conversation

@YoshiRulz
Copy link
Member

@YoshiRulz YoshiRulz commented Sep 24, 2022

Sorta like C# 8 default interface methods, but the base implementations are filled in at compile-time. Applying the attribute like this:

[VirtualMethod]
bool CanStep(StepType type);

generates

namespace BizHawk.Emulation.Cores.Atari.Atari2600
{
	public partial class Atari2600
	{
		bool BizHawk.Emulation.Common.IDebuggable.CanStep(BizHawk.Emulation.Common.StepType type)
			=> BizHawk.Emulation.Common.IDebuggable.MethodDefaultImpls.CanStep(this, type);
	}
}

unless the base implementation is overridden in that class. The base implementation being this:

public interface IDebuggable : IEmulatorService
{
public static class MethodDefaultImpls
{
public static bool CanStep(IDebuggable self, StepType type)
=> false;
}

TODO:

sorta like C# 8 default interface methods, but the base implementations are
filled in at compile-time
@YoshiRulz YoshiRulz force-pushed the virtual-interface-methods branch from 2a3d999 to 959cb29 Compare September 30, 2022 18:16
@YoshiRulz YoshiRulz added the Meta Relating to code organisation or to things that aren't code label Sep 26, 2025
@YoshiRulz YoshiRulz added the re: Metaprogramming Roslyn Analyzers and Source Generators label Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meta Relating to code organisation or to things that aren't code re: Metaprogramming Roslyn Analyzers and Source Generators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants