Skip to content

feat: improve specialization#215

Merged
elringus merged 6 commits into
mainfrom
feat/custom-event
Jun 7, 2026
Merged

feat: improve specialization#215
elringus merged 6 commits into
mainfrom
feat/custom-event

Conversation

@elringus

@elringus elringus commented Jun 5, 2026

Copy link
Copy Markdown
Owner

This adds CS and JSCtor parameters to [SpecializeImport] attribute, allowing to splice C# code into the generated C# proxy and JS code into the constructor of the generated JS proxy opening more ways to customize the specialized type behavior.

Also, when Decl start with export it will now replace the entire TypeScript declaration instead of splicing the content at the bottom of the default declaration.

These features, along with several fixes allow advanced specialization scenarios, for example turning properties of specific type into events on the JS side:

[SpecializeImport(typeof(Event<>),
CS:
"""
protected override object Unwrap () {
if (Event != null) return Event;
ImportedByEvent.Add(Event = new(), this);
Subscribe(Event.Broadcast);
return Event;
}
""",
JSCtor:
"""
const event = new Event();
event._id = _id;
this.subscribe(event.broadcast.bind(event));
return event;
""",
Decl:
"""
export interface Event<T extends (...args: never[]) => void> {
readonly last?: Parameters<T>;
subscribe(handler: T): string;
unsubscribe(handler: T): void;
broadcast: T;
}
""")]
public abstract class EventImport<T> (int id) : SpecializedImport(id) where T : Delegate
{
protected internal static readonly ConditionalWeakTable<Event<T>, SpecializedImport> ImportedByEvent = new();
protected Event<T>? Event;
public abstract void Subscribe (T handler);
}

Documentation: https://bootsharp.com/guide/specialization#injecting-code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c32a84a537

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cs/Bootsharp.Common/Attributes/SpecializeImportAttribute.cs
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (382b218) to head (835fb2f).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #215   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           60        60           
  Lines         2929      2965   +36     
  Branches       532       542   +10     
=========================================
+ Hits          2929      2965   +36     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2815aba49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cs/Bootsharp.Common/Interop/Instances.cs
@elringus elringus force-pushed the feat/custom-event branch from b2815ab to f70a139 Compare June 6, 2026 21:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f70a13973d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cs/Bootsharp.Publish/Common/Inspection/Meta/TypeMeta.cs
@elringus elringus merged commit f9342a1 into main Jun 7, 2026
8 of 10 checks passed
@elringus elringus deleted the feat/custom-event branch June 7, 2026 12:10
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