applying aspect defined in one project, to methods in other projects of solution - postsharp

I have created an aspect class inherited from OnMethodBoundaryAspect class of Postsharp. When I use the aspect in the same project where I have defined it, it works fine. But when I use the aspect in another project in my solution, the aspect would not be applied. In this case the PostSharp Explorer says "there is no aspect in the current solution, ..."
How can I solve this problem and use my aspect defined in project A to methods or classes in project B in my solution?
Thanks

Related

Custom control within framework not configurable or visible in Xcode

I have created a small selection of custom controls that are tagged #IBDesignable to enable visual configuration within IB. They work perfectly in their parent project/workspace and, as I wanted them to be reusable, I've created a framework.
After importing the framework into another project, I can access the classes programmatically but there is no visual representation in IB and none of the #IBInspectable properties are displayed in the attributes inspector. There are no errors reported during build or run phases. I guess I'm missing something somewhere but does anyone have any pointers?
It would appear that this is not currently possible (using Carthage as a dependency manager at any rate) without considerable effort with workarounds. This kind of defeats the object IMO!
For now it seems that you need to import the framework project into the product project. Explanation here but, for now, this seems dead in the water.

PostSharp aspect don't compile and fire

I have a problem with PostSharp, which in short can be described as "some aspects don't fire and are not shown in PostSharp Explorer".
As could be seen on a screenshot two aspects from Authorization namespace, which are inherited from MethodInterceptorAspect are presented in PostSharp explorer and two new aspects from ExceptionHandling namespace which are derived from OnExceptionAspect are not.
Below is a code of one of them: a 'standard' aspect made by manual, almost the same as working aspets except it derives from another base class. I tried to identify the problem commenting different parts of code but it didn't help.
[Serializable]
[AttributeUsage(AttributeTargets.All)]
public class HandleExceptionAttribute : OnExceptionAspect
{
/// <summary>
/// Method executed <b>after</b> the body of methods to which this aspect is applied,
/// in case that the method resulted with an exception (i.e., in a <c>catch</c> block).
/// </summary>
/// <param name="args">Advice arguments.</param>
public override void OnException(MethodExecutionArgs args)
{
// some exception handling code
}
}
Moreover I just added a simple aspect right from the sample and it also not shown in PostSharp Explorer.
Question
So the question is: why aspects don't compile and fire?
Unswering my own question / Question is updated
It seems it's a bug of PostSharp or maybe a conflict between PostSharp, ReSharper and Visual Studio.
After appling one of new aspects on abstract method (previously aspect was appliet at class level) I've got a build error about 'incompatibilty'. Then I made abstract method virtual and project compiled succesfully. And Resharper Explorer shown both new aspects with all their affects. To make it clear I made 'undo changes' and wanted to repeat my actions, but this time all aspects dissappeared from PostSharp Explorer like they are not applied at all (while they where still applied totally about 300 times) and ReSharper highlighted all aspects usages as uknown types.
After suspending ReSharper, clearing the solution, restarting the VisualStudio and rebuilding solution, three aspect appeared in PostSharp explorer and the forth one appeared after PostSharp was applied once again to the project, where this aspect was used.
So if your aspect don't fire - check your PostSharp setup in projects that use aspets.
Related questions and answers:
applying aspect defined in one project, to methods in other projects of solution
'Add PostSharp to this project' no action
Thanks to #Jakub for guiding comment!

Eclipse RCP propertychangelistener usage, the proper way?

I'm working on an editor to make changes to a list of emf objects. What I want is every time I modify those emf objects, my editor is to be refreshed to reflect the changes.
The approach I tried before was having a wrapper object over the said emf object (because I don't know how I can or should modify the emf-generated source code) to contain the editor needs to be refresh. The changes will be made on top of that wrapper object, and propertychangelistener is to be dispatched after emf object have been changed. However this solution is very ugly because:
Each object will need to obtain the reference to the editor itself, introducing a reference dependency
Having a separate overlay object like that introduces complication into maintaining the code
What is the right way to do it?
I think of adding binding framework to handle model object changes
You may want to look at following tutorial as a starting point.
http://www.vogella.com/articles/EclipseDataBinding/article.html

How to implement Quick Fix / Quick Assist for custom eclipse editor?

I have extended org.eclipse.ui.editors.text.TextEditor to implement a custom editor.
For this editor, I have defined a marker type (org.eclipse.core.resources.markers extension point) and an annotation type (org.eclipse.ui.editors.annotationTypes extension point) to mark specific parts of code in my editor. I use a reconciler to update my annotation model.
Now I want to add a quick fix / quick assist feature. I simply want eclipse, to show a box with proposals, when I hover over an annotated part of the code and replace that part with a given string, when I click on a proposal. Just like the quick fix feature for the java editor.
So, what is the best way to implement this behavior?
I read about marker resolution generators and quick assist processors, but I'm still confused how it all works together...
I would be glad, if someone could point me to the right direction.
EDIT: From what I've understood so far, a MarkerResolutionGenerator is responsible for showing quick fixes in the problems view. To get quick fixes in the source viewer, I would have to set a QuickAssistAssistant for my SourceViewer and implement a QuickAssistProcessor which returns CompletionProposals.
Is this the right way to do it?
EDIT2: I'm wondering if I need Markers at all, or only Annotations, I'm confused...
I finally found out how to get Quick Fix to work for my editor.
I use the annotationTypes extension point to register my own annotation type and the markerAnnotationSpecification extension point to specify the look and feel. In my custom SourceViewerConfiguration class I override getAnnotationHover(...) to return a DefaultAnnotationHover object and getTextHover(...) to return a DefaultTextHover object, so the annotations are shown in my source viewer.
Then I override getReconciler(...) to return a MonoReconciler with my own implementation of IReconcilingStrategy to create the annotations in its reconcile(...) method. And finally I override getQuickAssistAssistant(...) to return a QuickAssistAssistant with my own implementation of IQuickAssistProcessor. The computeQuickAssistProposals(...) method in the processor class computes the quick fix proposals which show up, when I press CTRL+1.
I don't create any Marker objects and don't use a MarkerResolutionGenerator, since the marker concept is much more heavyweight than using only annotations and the functionality which annotations provide fits my needs.
You have to register an extension to the extension point org.eclipse.ui.ide.markerResolution. This extension refers to a markerType (using the markerId), and also a resolution generator.
The latter component is responsible for calculating the possible fixes: it reads the marker, it can check the related files, etc., and creates marker resolution instances. These resolution instances basically process the erroneous files, and hopefully fix the original problem.
During marker resolution, you should not worry about removing the markers, as after the fix is executed, sometimes the validation would run again (e.g. during the build, or if no automatic validation is available, then manually - but it is not the task of the marker resolution to update the list of markers).

XCode class models: how to view Framework classes?

I'm using XCode 3.1.4, I'd like to browse the iOS framework classes visually, eg. the UIKit.framework classes.
I believe this is possible with Class Model facility, the documents here http://developer.apple.com/tools/xcode/xcodefuture.html suggest so:
The Xcode class modeler works with Objective-C, C++, and Java source code files and can give you a look at just a few classes, every class in your project, or even all of the classes in a framework.
I made a Class Model and selected Add All to include everything including the framework's .framework files. However on the generated diagram where I see UITableViewCell, it has no arrows pointing up from it, even though I know this class inherits from UIView. I've played with clicking various ways, the menus and Info but can't see how to see the full inheritance tree of UITableViewCell.
Can anyone advise?
This is what I did to make it work:
Select the project:
Then choose Quick Model:
Then you get a ridiculously large model with all the classes in it.
If you wanted the classes from just one framework, you could select just that framework in the files list, instead of the whole project.
I see the same thing in the Xcode Class Modeler, so it may be an issue with the tool or a choice made by its authors.
The method you used should give you a correct model, however you may need to move classes around to be able to see the arrows as there are way too many lines present if you model everything at once. The quick model will give the same results using the selection (i.e. if you select your project itself you get everything, and if you select a group of classes you will just get them.