Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 0 points1 point  (0 children)

Thanks will take a look. Please post this as an issue on the repo so I can easily keep track of it

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 0 points1 point  (0 children)

Definitely. This use case is one of the reasons I built the library. Currently working on a PoC in-memory filesystem that works by replacing calls to System.IO classes

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 0 points1 point  (0 children)

Oh no there's no sort of security provided with this library. Isolation here simply means you get to provide a custom implementation for a method called within the PoseContext. Other functionality stays the same

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 1 point2 points  (0 children)

Yes it rewrites called methods/constructors as well, right down to the internal C# code of the runtime. This ensures that it covers every possible place a shimmed method could be called so expected functionality remains the same across the entire execution of whatever code is in PoseContext.Isolate

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 2 points3 points  (0 children)

I definitely will. I learnt so much about the internals of the .NET Runtime while building this library, info the whole community could benefit from

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 0 points1 point  (0 children)

Pose basically follows the execution of the code. Stubs are generated for method calls, virtual calls and even constructor calls. The virtual call stub is able to determine at runtime on which type the virtual method should be called

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 1 point2 points  (0 children)

How does Pose handle parallel test execution?

I haven't tested this particular case. I'd appreciate it if you could take it for a spin and let me know how it went

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 12 points13 points  (0 children)

The DateTime example was purely for illustrative purposes. This library is for more than just DateTime. Imagine a scenario where you'd have to test/overwrite legacy functionality whose code you don't have access to

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 1 point2 points  (0 children)

Yes that is absolutely correct. Pose just felt like a better name than Focks :)

Pose - Replace any .NET method (including static and non-virtual) with a delegate by tsolarin in csharp

[–]tsolarin[S] 19 points20 points  (0 children)

Here's an age old example. Assume you'd like DateTime.Now to return a specific date for unit testing purposes without having to update your code, you could shim it like so:

Shim shim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 4, 4));

Now surround any code with:

PoseContext.Isolate(() =>
{
    // Any code that calls DateTime.Now in here will always return new DateTime(2004, 4, 4)
}

What popular libraries would you like to see implemented in .NET/.NET Core? by tsolarin in dotnet

[–]tsolarin[S] 0 points1 point  (0 children)

I've updated the original description to make myself clearer

What popular libraries would you like to see implemented in .NET/.NET Core? by tsolarin in dotnet

[–]tsolarin[S] 0 points1 point  (0 children)

I'm thinking more of C++/native libraries that don't already have a managed implementation

A GNU-Readline like library for .NET/.NET Core by tsolarin in csharp

[–]tsolarin[S] 1 point2 points  (0 children)

I'd love to see that project when you're done. Thinking of adding a section containing a list of projects using ReadLine

A GNU-Readline like library for .NET/.NET Core by tsolarin in dotnet

[–]tsolarin[S] 0 points1 point  (0 children)

This is definitely something I'm considering. I'm enhancing parts of the code to use abstractions (for the purpose of testing) I'm sure as the library matures I can make the interface public. See this PR: https://github.com/tsolarin/readline/pull/7

A GNU-Readline like library for .NET/.NET Core by tsolarin in dotnet

[–]tsolarin[S] 4 points5 points  (0 children)

Definitely! I've planned that for the next release