nathanAjacobs
nathanAjacobs
Explore posts from servers
CC#
Created by nathanAjacobs on 3/3/2025 in #help
Managed callback to native code (reverse p/invoke)
TIL what a thunk is
11 replies
CC#
Created by nathanAjacobs on 3/3/2025 in #help
Managed callback to native code (reverse p/invoke)
Okay I asked a LLM and it says this: "When you pass a managed delegate to native code via P/Invoke, the CLR automatically generates a thunk (a small, fixed bridge between native and managed code). This thunk has a fixed address in memory, even if the delegate or its target object (ManagedClass) is moved by the GC." Is this true?
11 replies
CC#
Created by nathanAjacobs on 3/3/2025 in #help
Managed callback to native code (reverse p/invoke)
Yeah I found out the garbage collection part the hard way lol. Can you provide more info on why it doesn't have to be pinned? Couldn't the memory address change if not pinned?
11 replies
CC#
Created by nathanAjacobs on 3/3/2025 in #help
Managed callback to native code (reverse p/invoke)
Yeah that's what I'm thinking too, but wanted to get confirmation
11 replies
CC#
Created by nathanAjacobs on 3/3/2025 in #help
Managed callback to native code (reverse p/invoke)
For example, I could have an unmanaged and managed representation of a class and have an instance id to track it between creation and disposal on the native side
11 replies
CC#
Created by nathanAjacobs on 3/3/2025 in #help
Managed callback to native code (reverse p/invoke)
Yeah I could, but I'm curious specifically about the semantics of an instanced callback.
11 replies
CC#
Created by nathanAjacobs on 2/21/2025 in #help
Would this AsyncQueue have issues with multiple producers and a single consumer?
Yeah I realized that, I added a CancellationToken to DequeueAsync.
18 replies
CC#
Created by nathanAjacobs on 2/21/2025 in #help
Would this AsyncQueue have issues with multiple producers and a single consumer?
Okay I'll take a look there too, thanks
18 replies
CC#
Created by nathanAjacobs on 2/21/2025 in #help
Would this AsyncQueue have issues with multiple producers and a single consumer?
Yeah I saw some too, that is what made me ask honestly. No worries!
18 replies
CC#
Created by nathanAjacobs on 2/21/2025 in #help
Would this AsyncQueue have issues with multiple producers and a single consumer?
True, I guess that would be a weird situation anyways. Thanks for the reassurance. Much appreciated!
18 replies
CC#
Created by nathanAjacobs on 2/21/2025 in #help
Would this AsyncQueue have issues with multiple producers and a single consumer?
Yeah that is what I thought, I think there are no issues. I think it would only be a problem if there were multiple consumers since I think the semaphore and dequeue operation could get out of sync
18 replies
CC#
Created by nathanAjacobs on 2/21/2025 in #help
Would this AsyncQueue have issues with multiple producers and a single consumer?
The library supports Unity versions before .NET Standard 2.1 was added
18 replies
CC#
Created by nathanAjacobs on 2/10/2025 in #help
How can I reference multiple generics in summary?
Yeah I left it off there by mistake, I was just showing the documentation portion. That is a good point though
14 replies
CC#
Created by nathanAjacobs on 2/10/2025 in #help
How can I reference multiple generics in summary?
And links don't work
14 replies
CC#
Created by nathanAjacobs on 2/10/2025 in #help
How can I reference multiple generics in summary?
Yeah, you're right. It just shows the summary all in white.
14 replies
CC#
Created by nathanAjacobs on 2/10/2025 in #help
How can I reference multiple generics in summary?
This might be slightly better because the links actually go to the right type, however the types lose the the appropriate highlighting and just appear blue.
/// <summary>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>
/// A <see cref="Task{_}">Task</see>&lt;<see cref="Handle{_}">Handle</see>&lt;<typeparamref name="T"/>&gt;&gt;
/// </returns>
public Task<Handle<T>> Foo<T>()
{
return default;
}
/// <summary>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>
/// A <see cref="Task{_}">Task</see>&lt;<see cref="Handle{_}">Handle</see>&lt;<typeparamref name="T"/>&gt;&gt;
/// </returns>
public Task<Handle<T>> Foo<T>()
{
return default;
}
14 replies
CC#
Created by nathanAjacobs on 2/10/2025 in #help
How can I reference multiple generics in summary?
So this is definitely a hack, as it requires a non generic type to exist and it obviously links to that non generic type if clicked on. This at least gets the highlighting correct though in the summary when hovering over the method in Visual Studio.
/// <summary>
/// You can access the Result from the <see cref="AsyncOperationHandle"/>&lt;<typeparamref name="T"/>&gt; after awaiting assuming the load did not fail.
/// </summary>
/// <returns>
/// An awaitable <see cref="UniTask"/>&lt;<see cref="AsyncOperationHandle"/>&lt;<typeparamref name="T"/>&gt;&gt; instead of <see cref="UniTask"/>&lt;<typeparamref name="T"/>&gt;
/// because as the caller you are responsible for releasing the handle when appropriate.
/// </returns>
public static async UniTask<AsyncOperationHandle<T>> LoadAssetAsync<T>(object key)
{
}
/// <summary>
/// You can access the Result from the <see cref="AsyncOperationHandle"/>&lt;<typeparamref name="T"/>&gt; after awaiting assuming the load did not fail.
/// </summary>
/// <returns>
/// An awaitable <see cref="UniTask"/>&lt;<see cref="AsyncOperationHandle"/>&lt;<typeparamref name="T"/>&gt;&gt; instead of <see cref="UniTask"/>&lt;<typeparamref name="T"/>&gt;
/// because as the caller you are responsible for releasing the handle when appropriate.
/// </returns>
public static async UniTask<AsyncOperationHandle<T>> LoadAssetAsync<T>(object key)
{
}
14 replies
CC#
Created by nathanAjacobs on 2/10/2025 in #help
How can I reference multiple generics in summary?
Yeah true
14 replies
CC#
Created by nathanAjacobs on 2/10/2025 in #help
How can I reference multiple generics in summary?
Man that issue was created in 2017, it's almost been 8 years
14 replies
CC#
Created by nathanAjacobs on 2/10/2025 in #help
How can I reference multiple generics in summary?
This is sad 😦
14 replies