3 comments
Avatar
Permanently deleted user

Hello Eugene,

Wow - thanks a lot - the document covers most of the problems I had with
Agent Johnson.

The one thing which cost me most grief, is however not mentioned.

It is in most cases no longer possible to cast between a declaration and
an implementation(?).

For instance, I had a lot of code like:

IFunctionDeclaration functionDeclaration = ...;

IFunction function = functionDeclaration as IFunction;
if (function == null) {
return;
}


This worked in 4.1, but in 4.5 it does not, as function will be null.

Instead this works:

IFunctionDeclaration functionDeclaration = ...;

IFunction function = functionDeclaration.DeclaredElement as IFunction;
if (function == null) {
return;
}


It makes a lot more sense and is cleaner, but, boy, I had to change a lot
of code.

--Jakob

Hi, ReSharper PlugIn Developers!

We've created the first draft of the plugin migration guide:

http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+PlugIn
4.0(4.1)to4.5Migration+Guide

If you would like additional topics to be covered, please let me know!



0

Hello Jakob,

The fact that IFunctionDeclaration and IFunction were implemented on a single
type was just that - implementation detail. It was never safe to rely on
this. In this release, we splitted declaration and declared element types,
for performance and memory usage reasons.

Also, DeclaredElement on IFunctionDeclaration is of type IFunction already,
so why do you have cast there?

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


JC> Hello Eugene,
JC>
JC> Wow - thanks a lot - the document covers most of the problems I had
JC> with Agent Johnson.
JC>
JC> The one thing which cost me most grief, is however not mentioned.
JC>
JC> It is in most cases no longer possible to cast between a declaration
JC> and an implementation(?).
JC>
JC> For instance, I had a lot of code like:
JC>
JC> IFunctionDeclaration functionDeclaration = ...;
JC>
JC> IFunction function = functionDeclaration as IFunction;
JC> if (function == null) {
JC> return;
JC> }
JC> This worked in 4.1, but in 4.5 it does not, as function will be
JC> null.
JC>
JC> Instead this works:
JC>
JC> IFunctionDeclaration functionDeclaration = ...;
JC>
JC> IFunction function = functionDeclaration.DeclaredElement as
JC> IFunction;
JC> if (function == null) {
JC> return;
JC> }
JC> It makes a lot more sense and is cleaner, but, boy, I had to change
JC> a lot of code.
JC>
JC> --Jakob
JC>
>> Hi, ReSharper PlugIn Developers!
>>
>> We've created the first draft of the plugin migration guide:
>>
>> http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+PlugI
>> n 4.0(4.1)to4.5Migration+Guide
>>
>> If you would like additional topics to be covered, please let me
>> know!
>>


0
Avatar
Permanently deleted user

Hello Ilya,

I agree that it is the right decision to split declaration and declared element
types - I guess I abused the API without really knowing it :-).

And, sorry, I do not cast - I was just typing the code directly in the post
and forgot that DeclaredElement is strongly typed.

I just think it is worth mentioning in your excellent document, that such
an abusive cast no longer works.

--Jakob

Hello Jakob,

The fact that IFunctionDeclaration and IFunction were implemented on a
single type was just that - implementation detail. It was never safe
to rely on this. In this release, we splitted declaration and declared
element types, for performance and memory usage reasons.

Also, DeclaredElement on IFunctionDeclaration is of type IFunction
already, so why do you have cast there?

Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

JC>> Hello Eugene,
JC>>
JC>> Wow - thanks a lot - the document covers most of the problems I had
JC>> with Agent Johnson.
JC>>
JC>> The one thing which cost me most grief, is however not mentioned.
JC>>
JC>> It is in most cases no longer possible to cast between a
JC>> declaration and an implementation(?).
JC>>
JC>> For instance, I had a lot of code like:
JC>>
JC>> IFunctionDeclaration functionDeclaration = ...;
JC>>
JC>> IFunction function = functionDeclaration as IFunction;
JC>> if (function == null) {
JC>> return;
JC>> }
JC>> This worked in 4.1, but in 4.5 it does not, as function will be
JC>> null.
JC>> Instead this works:
JC>>
JC>> IFunctionDeclaration functionDeclaration = ...;
JC>>
JC>> IFunction function = functionDeclaration.DeclaredElement as
JC>> IFunction;
JC>> if (function == null) {
JC>> return;
JC>> }
JC>> It makes a lot more sense and is cleaner, but, boy, I had to change
JC>> a lot of code.
JC>> --Jakob
JC>>
>>> Hi, ReSharper PlugIn Developers!
>>>
>>> We've created the first draft of the plugin migration guide:
>>>
>>> http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+Plug
>>> I n 4.0(4.1)to4.5Migration+Guide
>>>
>>> If you would like additional topics to be covered, please let me
>>> know!
>>>


0

Please sign in to leave a comment.