ILMerged Classes Not Visible To Resharper - resharper

I have ILMerged some assemblies. For example:
Foo.Bar
Bar.Foo
Foo.Baz
Into one assembly. For example:
FooBarBaz.Merged
And it works. That is, when I reference FooBarBaz.Merged and use something like Foo.Bar.MyClass in code it compiles just fine.
However Resharper (v5) does not work. Usages of any type from the merged assembly are bloody red. What's worse, I get no intellisense for these types either. Basically this assembly cannot coexist with Resharper.
I wonder if there's some ILMerge param that can cure this. ILMerge documentation is pretty well hidden, but I found this. I have hacked at various switches...to no avail.
Alternately, is there some Resharper setting I can change. I really prefer not to have to do this because this is an OSS project.

I have solved this. It's a bug in Resharper, I beleive. However it's not a bug that matters to me.
It seems that Resharper has trouble seeing types of an ILMerged assembly if the project that references that assembly is inside a solution that contains some of the assemblies that got merged. This is not a case that I care about.
I learned this from this thread.

For anyone who wants this fixed please go here to vote up support for ILMerged assemblies in R#: http://youtrack.jetbrains.com/issue/RSRP-192616

Related

How can I rearrange Kotlin code in the order?

First of all, I Google it, and find no answer to this. Also, I've found some questions here, but they dated 2016 and 2017. Now we have 2019.
I'm used to Java in Android Studio. When I override methods, IDE puts them in order - how they placed in parent class or implemented interface.
Also when I'm developing, for example, Repository pattern:
I create an interface.
Create classes which implements this interface
When I am adding functions in interface and then I override (ctrl+o, or alt+Enter on class name) them in my classes: In Java they placed at the same position as they defined in my interface, In Kotlin - the placed in top of the class (this is really bad!)
Also, code does not get reformatted automatically, for example: global vars placed on top, then goes constructors, etc.
So I'm asking.
It's just me? I've tried deleting all Android Studio settings, reinstalling, etc. It did nothing. Also, Googling did not take any results.
Is there any solution to all of this? Because I really liked kotlin, but this inconvenience is just very annoying.
Maybe this plugin Kotlin Code Sorter can fulfill your request. But this plugin only distinguishes the property, class, constructor or function. That the differences are inside some topics likes private, lateinit, val or var can not be order.
Android Studio/IntelliJ official doesn’t have support for the Kotlin code rearrangement.
First select that code which you want to rearrange or reformatted.
Than Just press ctrl+alt+L for rearrange or reformatted code.

Recommended way to find out what Liferay module provides a class

In my Liferay module, I want to use Liferay's SomeConvenientClass.
What is the recommended way to find out what module provides that class?
So that I can quickly add it to my build.gradle.
Ideally it should either:
return the module's group/name/version,
or say with certitude that this class does not exist in Liferay or is not exported.
Until now I go by trial-and-error and copy/paste from build.gradle files found in the wild, but I am looking for a more reliable method.
I have Liferay installed, and the source code of the exact same Liferay version, if that helps.
I tried mvnrepository but it does not seem to return anything, example: https://mvnrepository.com/search?q=AuditMessageProcessor
Have you tried http://search.maven.org/#advancedsearch ?
For example:
http://search.maven.org/#search|ga|1|c:"AuditMessageProcessor"
This is more an option than a real thing, but this is how I normally do:
be familiar with package naming conventions used by liferay and
inside apps: api, service, web...
be familiar with the bundle structure used by liferay, as their
use of resource folders, which are not so obvious sometimes...
With that in mind, normally on github is enough to navigate: portal->(kernel/impl/services/apps)->app service/api/web...
But this is a natural process that comes when you spend your day inside the code.
Normally, online jar locators help, but quite often I just rely on my IDE.
On my IDE I have all set-up with Spring dependency management, after I extracted the dependencies using Gogo shell with a running bundle. With Gogo you will not find classes, but modules and packs will be listed. (Gogo is probably what you are looking for btw, as it is able to list with version numbers)
Bottom line, if you need a list as a picture of a running environment, use Gogo.
With regards to the master code, just do not trust it! When it comes to modularity and bundles versioning Liferay is pretty messy (read The dependency management problem here: https://www.e-systems.tech/blog/-/blogs/liferay-digital-experience-platform-review-7-0-ga4).
For your step 7, you will need to chose an api version and code against it. The apis are more stable. You can impose a limit for compatibility on you bnd file, which will cause the system to issue warnings. On your environment, you can catch api changes earlier, let's say, you can ask gradle to use a module with an version number but any patch (using the "+" sing), when you build with a fresh cache or if you change gradle resolution strategy to download you dependencies more frequently, if the build breaks, well, you will see it.
Helpful start point: https://dev.liferay.com/pt/develop/reference/-/knowledge_base/7-0/using-the-felix-gogo-shell
This is how I do, it is slow and manual, so don't hesitate to suggest other methods.
Download Liferay's source code if you don't have it already.
Run find . -name SomeConvenientClass.java. If nothing is found, you can be sure the class is not part of Liferay.
In the path to the class, find the src folder level, and go just under that, so for instance if it is modules/apps/collaboration/document-library/document-library-web/src/main/java/com/liferay/document/library/web/portlet/action/DLViewMVCRenderCommand.java then go to modules/apps/collaboration/document-library/document-library-web/.
Hopefully there is a bnd.bnd file there, open it.
If the package of the class is not in the Export-Package section, then either give up (duplicate Liferay's code into your module), or use some dark tricks. If you believe the class should be exported, you can explain your case at https://issues.liferay.com/browse/LPS-70480 for future generations to enjoy.
Module name is the value of Bundle-SymbolicName.
Version is the value of Bundle-Version.
Group is probably com.liferay, although sometimes it is com.liferay.portal, not sure how to tell.
Build. Sometimes it fails because Maven repositories are missing a version, for instance com.liferay.document.library.web 1.0.11 is not available despite being used by DXP fix pack 30. Not sure what to do in such cases except choosing a "similar" version and hoping for the best.

system.runtime.serialization and mvvmcross

I am stuck with this issue and I cant seem to solve it. I have my logic in a PCL and a a .Droid and .iOS clients.
I need to use the [serializable] attribute in my logic so I need to add a reference to system.runtime.serialization. The problem is there is a different dll for android and iOS how can I manage this? I did not encounter this problem before because I used shared files between the projects so each project had its own reference to the correct system.runtime.serialization and I could use the [serializable] attribute with no problems.
Have I missed something?
Thanks
Amit
In general I'd recommend avoiding trying to use the SerializableAttribute in portable code. That type of serialization is basically not portable. However, if you really need to do it, that attribute is actually treated specially and is represented by a bit on the type as opposed to a normal attribute. So if you define your own attribute with the same name and namespace in a PCL, the compiler will emit the bit and everything may just work like you need it to.

CodeContracts and resharper vs2012 not working

I have Resharper and it's a fantastic tool
Starting a projects and I need to use CodeContracts. However Resharper ignores them.
After checking a few blogs I came across this one:
http://www.infinitec.de/post/2010/11/18/Using-Code-Contracts-Visual-Studio-and-with-Resharper.aspx
However I get an error
Error 2
The command ""C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite"
"#MyProject.Coreccrewrite.rsp"" exited with code 1.
Has anybody managed to have codecontracts and resharper to work together?
Edited
What I am doing is
Trying to use codeContract and resharper gives a Method invocation is skipped etc..
Googled and found lots of people with same problem and no solution.
As you can see I attached a link that should have done the trick but didnt
Create a new project in vs2012 and try to use code contract and resharper will not let you.
It will be disabled and if you enable it you get another error
Comment from Resharper team on
http://youtrack.jetbrains.com/issue/RSRP-182553#comment=27-200330
ReSharper will not support "Code Contracts" as is in the mid-term
future. There are 2 main reasons for this:
CodeContracts are written in the code block, and, moreover, in the separate assembly. ReSharper requires contracts to be at the
metadata level
Current contract are too complex and are not supposed to be analyzed in real-time.
During ReSharper development, we analyze CodeContracts and building
corresponding ReSharper code annotation marks. We are going to extent
our annotations, and always keep them in-sync with contracts.
I am stuffed!!!

Can ReSharper automatically add missing references?

I just started using VS2008 and ReSharper.
I have a line:
Microsoft.Office.Server.Diagnostics.PortalLog.LogString("*** BOO Feature activating ***");
VS shows "Office" as red because it cannot resolve symbol "Office".
Can I make ReSharper just add the reference automatically, or do I need to manually surf to the reference and add it?
R# will not add the reference automatically but once you do it (manually) it will suggest the correct namespaces for you.
To get the best out of resharper in relation to referencing assemblies and adding using statements don't plan ahead. When coding don't put in any references our using statements just start typing the code:
public class MyClass
{
Foo foo = new Foo();
}
Initially "Foo" will be highlighted to indicate it cannot resolve the symbol, place your caret on "Foo" and either hit your short cut for the resharper hot fix (Alt + Enter) or click on the red light bulb.
If any of the other projects in your solution reference the assembly that contains "Foo" or it is in the core .net library you will get the option to "Reference '{Foo's Assembly}' and use '{Foo's namespace}.Foo'".
If your project already contains the reference you will get the option to use {Foo's namespace}.Foo.
If it cannot resolve the assembly you will need to add it the once but after that either option 1 or 2 will apply.
If you think about how large the framework is, plus any potential third party assemblies in the GAC...you start to see why when a type's not found Resharper looking through them all for it is a really bad idea for performance.
A typo would leave you with a coffee break while it looks. Also, what if it did find the type, nothing says 2 third party assemblies couldn't define it, or 2 or more versions of that assembly in the GAC, etc.
It's better to leave the decision up to you to reference exactly what you want, and that's what it does, for performance and explicitness.

Resources