zompinc / zompinc/sync-method-generator

Feature: User defined mapping

Open
#92 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
84
Forks
11
Avg merge
10h 50m
Merged PRs (30d)
12

Description

It would be nice, if you could define your own mapping for the async-to-sync function conversion.

Example:

NHibernate.Linq.LinqExtensionMethods.ToListAsync=System.Linq.Enumerable.ToList

Currently, this source code generator tries to use NHibernate.Linq.LinqExtensionMethods.ToList, which doesn't exist and requires to write your own class, like:

namespace NHibernate.Linq;

internal static class LinqExtensionMethods
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static List<T> ToList<T>(IQueryable<T> query)
        => query.ToList();
}

This, however, comes with its own problems:

  • Complaints that the namespace doesn't match the directory structure/root namespace of the project
  • Warning CS0436, because there is a static class in both the NHibernate assembly and your own project

The mapping could be stored in a file included with AdditionalFiles, like the CsWin32 project does.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the source code generator entry point that performs async-to-sync method conversion and reviewing how AdditionalFiles are exposed. Define how the mapping file represents entries such as the ToListAsync example, then verify that configured mappings are used instead of generated wrapper methods without requiring user-defined classes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.