Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Source Generator which adds virtual interface methods to C# #3393

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant