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

Feeback #4

Open
Puresharper opened this issue Aug 15, 2018 · 15 comments
Open

Feeback #4

Puresharper opened this issue Aug 15, 2018 · 15 comments
Assignees

Comments

@Puresharper
Copy link
Owner

Puresharper commented Aug 15, 2018

Hi everyone,

Don't hesitate to leave me here some comments to encourage me... or not :)
Just tell me what you want or need here about this project.

@Puresharper Puresharper self-assigned this Aug 15, 2018
@buiminhhuy
Copy link

buiminhhuy commented Dec 24, 2018

Could The project convert to .Net Core 2.1? I am very excited with this concept AOP in your framework. I have tried convert to .Net Core 2.x, but I got some out update issues.

@Puresharper
Copy link
Owner Author

Puresharper commented Jan 2, 2019

Hi,
Sorry for anwsering only now... (chrismas & new year days)

Sure, I hope I can convert this project entirely in .NET Core 2.1 but I have to try first Mono Cecil capability before or find an alternative to do it. I may work on this month.

EDIT : I just test it! and mono cecil v0.10.1 seems to work better for dotnet core.
I will try to make as soon a possible a new version of Puresharp with dotnet core 2.1 support.

@MisterLight
Copy link

MisterLight commented Jan 7, 2019

I also excited with your AOP framework, Im trying to implement it in Unity but I find some issues, i think it would be because Unity implement .NET Standard api, btw, I try the framework in a .net core console app, and look like its the same error that i got with unity

System.TypeInitializationException: 'The type initializer for 'Puresharp.Aspect' threw an exception.'

Inner Exception
MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.

@Puresharper
Copy link
Owner Author

Puresharper commented Jan 8, 2019

Hi,

Thank your for interesting, your issue look like you try to use Puresharp in .NET standard or Core while it is not yet supported. If you let me a single scenario that produce the same kind of bug, I can diagnostic it.

The method 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)' does not exist in .net core but exists in .net 4.5.2 and may no exists in .net standard specification.

So, I actively work on full .net core support. I just got some little issue (Assembly Resolver in mono cecil for .net core with dependencies) that I have to fix to publish a new major version manage .net core.

Maybe in a second way, I will try to support .NET standard but it is not in my prior roadmap due to ratio betwwen efforts & benefits.

@Puresharper
Copy link
Owner Author

Good news Puresharp 5.0 support .net core 2.1+ project.

@Puresharper
Copy link
Owner Author

Some issues was introduced in first versions of Puresharp 5 due to mono cecil v0.10.1 migration.
Please use versions greater than or equal to : Puresharp 5.0.5

@dayanfcosta
Copy link

Some things are no clear in the tutorial, like

Instantiate Aspect and weave it to our ReadonlyOperation Pointcut

Where to instantiate the aspect?

@Puresharper
Copy link
Owner Author

Where you want but prefer somewhere at application startup...
In Application.Start of global class in ASP.net app for example.

@eightrivers
Copy link

We had used NConcern for several times, and now try to migrate to Puresharp, since dotnet core platform should also be supported now .

We notice that the interface has been redesigned comparing with the old version in NConcern.

for example, in NConcern, the instance and the arguments could be put into a lambda epression like this:

 yield return Advice.Basic.Before((instance, arguments) => 
        {
            Tracer.Trace(method, arguments);
        });

But in Puresharp, we need to combine several type of express to do the same thing like this:

yield return Advice
            .For(method)
            .Before(invocation =>
            {
                return Expression.Call
                (
                    Metadata.Method(() => Console.WriteLine(Metadata<string>.Value)), 
                    Expression.Constant($"Expression : { method.Name }")
                );
            });

So what we are thinking in mind is that what is the reason for this redesign in background, efficiency, extensionbility, or something else?

And more, would you plesae provide a example which covers the features as listed below, or show some tips on how to implement it.

  • catch the object and the arguments in the "Before" method
  • change the value of the arguments in the "Before" method
  • cancel the execution of the orginal method body, if needed
  • catch the output of the orginal method, and change the value, if needed

Thanks!

@Puresharper
Copy link
Owner Author

Hi, thank you for interesting.

You're right Puresharp have been redesigned compared to NConcern.
Indeed, fore some reasons (globally efficiency, non implicit overhead injection and async support), some extensions methods used to create an advice are missing in Puresharp.
Method provided in Puresharp have to be totally "Pure".

The method you looking for have to implicitly create an object array and box all arguments that represent an hidden overhead and may by the same occasion drive you in reflection implementation instead of expression.

However, theses methods are implemented in "Puresharp.Underground" as extension methods. "Puresharp.Underground" is not currently available (but soon).

All you need can be implemented by using directly "IAdvice" :
yield return Advice .For(method) .Around(() => new MyAdvice(method));

where "MyAdvice" implements "IAdvice"

Indeed, by implementing "IAdvice" pattern, You can control the arguments, return and exception because they are always passed as REF parameter that allow you to swap them as you want.

To cancel execution, you can throw an exception in "Begin" method of IAdvice and Manage this exception in "Throw" Method that allow you to cancel exception by set it to null and provide a valid return value.

@dmusicand
Copy link

How do I prevent the original method from being executed and instead return my own value? I didn't see any code that shows this.

As an example, I would like this sequence:

  1. When my advice is called, check some cache for a value based on the argument passed
  2. If the cache holds that value, then don't call the original method, instead return the cached value
  3. Otherwise, call the original method and capture its return value and cache that based on the argument to the method

@pamidur
Copy link

pamidur commented Jun 14, 2019

Hi,
Just a word of appreciation from fellow AOP framework developer :). Good job!

@Puresharper
Copy link
Owner Author

Puresharper commented Sep 2, 2019

Hi,

Sorry to have been away for a while, I was expecting the birth of my 2nd child and it took a long time.

dmusicand,
Currently there is no way to prevent code execution since I redesign the product to manage async methods. I take this fact as considération to add some support for your legitim needs.

pamidur,
Thank you for the encouragement, it particularly affects me a developer of AOP framework :)

@Curlack
Copy link

Curlack commented Sep 12, 2019

Hi Tony,
First I would like to thank you for Puresharp, it's amazing.

Next I would like to know what the impact would be, if IPuresharp.Authority.Modules also ignore references starting with "Microsoft." (like it's doing with "Puresharp." and "System.")?

The reason I'm asking is, the project I'm currently using Puresharp in, throws StackOverflowException. As far as I could see, there seems to be circular references between [PresentationFramework and ReachFramework] and [WindowsBase and UIAutomationTypes] (probably WPF, but I'm not referencing directly). I do have a reference to Microsoft.TeamFoundation.Client though (which I'm thinking is causing this, didn't make much sense of the rest).

Ignoring both "PresentationFramework" and "WindowsBase" makes the issue go away, but I don't like to single out specific assemblies (when will the list stop growing?).
Ignoring assemblies that starts with "Microsoft." also make the issue go away and it seems to fit the pattern of ignoring top level assemblies i.e. "System." and "Puresharp."

Regards

@Puresharper
Copy link
Owner Author

Hi Curlack,

Thank you for your message.

There is no impact to ignore kind of assemblies that starts with "Microsoft.". I probably have to manage circular reference because I know that can happend especially in framework assemblies.

Ignoring Puresharp. and System. is a temporary fix.

I will take time to think about how to correctly filter "unmanaged assembly" from IPuresharp and how to manage circular references.

Any suggestion would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants