QuickFix adds alias instead of complete namespace

Before:

namespace Example {

class Test
{

public void SetUp()
{
}
}
}

When I QuickFix to add the missing usings, R2 adds this line only:

using TestFixture = NUnit.Framework.TestFixtureAttribute;

This didn't happened in build 203.

Regards,
Pablo

6 comments
Comment actions Permalink

Hello Pablo,

Most probably there is some type in NUnit.Framework namespace that would
produce ambiguity if 'using NUnit.Framework' is inserted. Could you replace
'using TestFixture = NUnit.Framework.TestFixtureAttribute' with 'using NUnit.Framework'
and check if there are errors in the file?

Thanks,
Andrey Simanovsky


0
Comment actions Permalink

ands@intellij.com wrote:

Hello Pablo,

Most probably there is some type in NUnit.Framework namespace that would
produce ambiguity if 'using NUnit.Framework' is inserted. Could you
replace 'using TestFixture = NUnit.Framework.TestFixtureAttribute' with
'using NUnit.Framework' and check if there are errors in the file?

Thanks,
Andrey Simanovsky

It works correctly if I do the replace. As I said, this behavior is new
to build 204, build 203 worked correctly and did the right thing.

The only types that are to be imported from the NUnit.Framework
namespace are TestFixtureAttribute and SetUpAttribute.

Maybe its just me that's having this problem?

Pablo

0
Comment actions Permalink

Hello Pablo,

I cannot reproduce the problem with build 204.
ReSharper inserts 'using SomeClass1 = SomeNamespace1.SomeClass' if there
is already 'using SomeNamespace2' present and both, SomeNamespace1 and SomeNamespace2,
contain classes with the same name (e.g. SomeClass2). So, after removal there
are should be ambiguity errors with some SomeClass2. If it is not so it is
most likely a bug.
Could you try to remove other usings in the file, and run the QuickFix on
TestFixture?

It works correctly if I do the replace. As I said, this behavior is
new to build 204, build 203 worked correctly and did the right thing.

The only types that are to be imported from the NUnit.Framework
namespace are TestFixtureAttribute and SetUpAttribute.

Maybe its just me that's having this problem?

Pablo

Thanks,
Andrey Simanovsky


0
Comment actions Permalink

ands@intellij.com wrote:

Hello Pablo,

I cannot reproduce the problem with build 204.
ReSharper inserts 'using SomeClass1 = SomeNamespace1.SomeClass' if there
is already 'using SomeNamespace2' present and both, SomeNamespace1 and
SomeNamespace2, contain classes with the same name (e.g. SomeClass2).
So, after removal there are should be ambiguity errors with some
SomeClass2. If it is not so it is most likely a bug.
Could you try to remove other usings in the file, and run the QuickFix
on TestFixture?

>> It works correctly if I do the replace. As I said, this behavior is
>> new to build 204, build 203 worked correctly and did the right thing.
>>
>> The only types that are to be imported from the NUnit.Framework
>> namespace are TestFixtureAttribute and SetUpAttribute.
>>
>> Maybe its just me that's having this problem?
>>
>> Pablo
>>

Thanks,
Andrey Simanovsky

OK, I'll be more detailed.

I create a new file, and put this:

using System;

namespace Example.Core
{

public class ExampleTest
{
public void
SetUp()
{
}
}
}

If I QuickFix on TestFixture the correct thing happens, and a using
NUnit.Framework appears below the System using.

If I add to SetUp(), and do a QuickFix, then the bad behavior
ensues...

Can you still not reproduce this?

Pablo

PS: Ummm...I removed the file from the project, created it again (with
the same name, and while trying to add the I get this
exception:

JetBrains.ReSharper.Util.InternalErrorException: An exception has
occurred during event dispatching --->
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.IndexOutOfRangeException:
Index was outside the bounds of the array.
at
JetBrains.ReSharper.Editor.Impl.LineSegmentArrayList.get_Item(Int32
index) in
c:\TEMP\tmpABD0.tmp\src\DocumentModel\src\impl\LineSegment.cs:line 91
at
JetBrains.ReSharper.Editor.Impl.SimpleLineIndex.FindLineByOffset(Int32
offset) in
c:\TEMP\tmpABD0.tmp\src\DocumentModel\src\impl\SimpleLineIndex.cs:line 44
at
JetBrains.ReSharper.Editor.Impl.SimpleLineIndex.GetCoordsByOffset(Int32
offset) in
c:\TEMP\tmpABD0.tmp\src\DocumentModel\src\impl\SimpleLineIndex.cs:line 100
at
JetBrains.ReSharper.Editor.Impl.DocumentBase.GetCoordsByOffset(Int32
offset) in
c:\TEMP\tmpABD0.tmp\src\DocumentModel\src\impl\DocumentBase.cs:line 121
at
JetBrains.ReSharper.CodeInsight.LastEditLocation.LastEditLocationTracker.Suits(RecentEditLocation
location, IDocument document, Int32 offset) in
c:\TEMP\tmpABD0.tmp\src\CodeInsight\src\LastEditLocation\LastEditLocationTracker.cs:line
180
at
JetBrains.ReSharper.CodeInsight.LastEditLocation.LastEditLocationTracker.OnDocumentChanged(DocumentChangeEventArgs
d) in
c:\TEMP\tmpABD0.tmp\src\CodeInsight\src\LastEditLocation\LastEditLocationTracker.cs:line
136
at
JetBrains.ReSharper.Editor.Impl.DocumentManagerImpl.DispatchDocumentChanged(IChangeMap
map, DocumentChangedEventHandler handler) in
c:\TEMP\tmpABD0.tmp\src\DocumentManager\src\impl\DocumentManagerImpl.cs:line
180
at
JetBrains.ReSharper.CodeInsight.LastEditLocation.LastEditLocationTracker.OnChange(Object
sender, ChangeEventArgs changeEventArgs) in
c:\TEMP\tmpABD0.tmp\src\CodeInsight\src\LastEditLocation\LastEditLocationTracker.cs:line
65
--- End of inner exception stack trace ---
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean verifyAccess)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at JetBrains.ReSharper.Util.Events.EventDispatcher.Invoke(Delegate
listener) in
c:\TEMP\tmpABD0.tmp\src\Util\src\events\EventDispatcher.cs:line 147
--- End of inner exception stack trace ---

at JetBrains.ReSharper.Util.Logger.LogExceptionEx(Exception, String,
Boolean) in c:\TEMP\tmpABD0.tmp\src\Util\src\Logger.cs:line 285 column 9
at JetBrains.ReSharper.Util.Events.EventDispatcher.Invoke(Delegate) in
c:\TEMP\tmpABD0.tmp\src\Util\src\events\EventDispatcher.cs:line 151 column 9
at JetBrains.ReSharper.Util.Events.EventDispatcher.RaiseEvent(Object[])
in c:\TEMP\tmpABD0.tmp\src\Util\src\events\EventDispatcher.cs:line 130
column 55
at
JetBrains.ReSharper.Shell.Impl.ChangeManagerImpl.OnProviderChanged(IChangeProvider,
IChange, ITaskExecutor) in
c:\TEMP\tmpABD0.tmp\src\Shell\src\impl\changes\ChangeManagerImpl.cs:line
421 column 13
at
JetBrains.ReSharper.Editor.Impl.DocumentBase.HandleDocumentChange(DocumentChangeEventArgs,
Int32, Boolean) in
c:\TEMP\tmpABD0.tmp\src\DocumentModel\src\impl\DocumentBase.cs:line 220
column 9
at
JetBrains.ReSharper.Editor.Impl.DocumentBase.HandleDocumentChange(DocumentChangeEventArgs,
Int32) in
c:\TEMP\tmpABD0.tmp\src\DocumentModel\src\impl\DocumentBase.cs:line 199
column 5
at
JetBrains.ReSharper.Editor.VSIntegration.HandleDocumentChangeAction.Run()
in
c:\TEMP\tmpABD0.tmp\src\VSIntegration\src\Editor\DocumentOperationHandlers.cs:line
200 column 7
at JetBrains.ReSharper.Shell.DeferredActionExecutor.Execute(Action) in
c:\TEMP\tmpABD0.tmp\src\Shell\src\changes\DeferredActionExecutor.cs:line
92 column 5
at
JetBrains.ReSharper.Editor.VSIntegration.VSDocumentOperationsHandler.OnChangeStreamText(Int32,
Int32, Int32, Int32) in
c:\TEMP\tmpABD0.tmp\src\VSIntegration\src\Editor\DocumentOperationHandlers.cs:line
214 column 5
at Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget.Exec(Guid&,
UInt32, UInt32, IntPtr, IntPtr)
at JetBrains.ReSharper.TextControl.VSIntegration.MyDelegator.Exec() in
c:\TEMP\tmpABD0.tmp\src\VSIntegration\src\TextControl\VSTextControl.cs:line
394 column 13
at
JetBrains.ReSharper.TextControl.VSIntegration.MyDefaultTypingHandler.Type(ITextControl,
Char, NextHandler) in
c:\TEMP\tmpABD0.tmp\src\VSIntegration\src\TextControl\VSTextControlManager.cs:line
113 column 7
at JetBrains.ReSharper.TextControl.Impl.NextWrapper.Next() in
c:\TEMP\tmpABD0.tmp\src\TextControl\src\impl\TextControlManagerImplBase.cs:line
195 column 7
at ReSharper.TypingHandler.Type(ITextControl, Char, NextHandler) in
c:\TEMP\tmpABD0.tmp\src\CodeInsight.Services\src\ParameterInfo\ParameterInfoPopupControllerImpl.cs:line
259 column 6
at JetBrains.ReSharper.TextControl.Impl.NextWrapper.Next() in
c:\TEMP\tmpABD0.tmp\src\TextControl\src\impl\TextControlManagerImplBase.cs:line
195 column 7
at
JetBrains.ReSharper.CodeInsight.CodeCompletion.TypingHandler.Type(ITextControl,
Char, NextHandler) in
c:\TEMP\tmpABD0.tmp\src\CodeInsight\src\codeCompletion\CodeCompletionController.cs:line
49 column 9
at JetBrains.ReSharper.TextControl.Impl.NextWrapper.Next() in
c:\TEMP\tmpABD0.tmp\src\TextControl\src\impl\TextControlManagerImplBase.cs:line
195 column 7
at JetBrains.ReSharper.LiveTemplates.TypingHandler.Type(ITextControl,
Char, NextHandler) in
c:\TEMP\tmpABD0.tmp\src\LiveTemplates\src\LiveTemplates\impl\LiveTemplateTracker.cs:line
58 column 9
at JetBrains.ReSharper.TextControl.Impl.NextWrapper.Next() in
c:\TEMP\tmpABD0.tmp\src\TextControl\src\impl\TextControlManagerImplBase.cs:line
195 column 7
at
JetBrains.ReSharper.CodeInsight.TypingAssist.CSharpTypingAssist.HandleLeftBracketorParenthTyped(Char,
ITextControl, NextHandler) in
c:\TEMP\tmpABD0.tmp\src\CodeInsight\src\TypingAssist\CSharpTypingAssist.cs:line
375 column 9
at
JetBrains.ReSharper.CodeInsight.TypingAssist.CSharpTypingAssist.Type(ITextControl,
Char, NextHandler) in
c:\TEMP\tmpABD0.tmp\src\CodeInsight\src\TypingAssist\CSharpTypingAssist.cs:line
100 column 11
at JetBrains.ReSharper.TextControl.Impl.NextWrapper.Next() in
c:\TEMP\tmpABD0.tmp\src\TextControl\src\impl\TextControlManagerImplBase.cs:line
195 column 7
at
JetBrains.ReSharper.TextControl.Impl.TextControlManagerImplBase.Type(ITextControl,
Char) in
c:\TEMP\tmpABD0.tmp\src\TextControl\src\impl\TextControlManagerImplBase.cs:line
154 column 44
at
JetBrains.ReSharper.TextControl.VSIntegration.VSTextControlManager.DoType(VSTextControl,
Char) in
c:\TEMP\tmpABD0.tmp\src\VSIntegration\src\TextControl\VSTextControlManager.cs:line
95 column 5
at
JetBrains.ReSharper.TextControl.VSIntegration.MyCommandFilter.Exec(Guid&,
UInt32, UInt32, IntPtr, IntPtr) in
c:\TEMP\tmpABD0.tmp\src\VSIntegration\src\TextControl\VSTextControl.cs:line
418 column 11
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr,
IntPtr, Int32, IntPtr, IntPtr)
at System.Windows.Forms.NativeWindow.DefWndProc(Message&)
at System.Windows.Forms.NativeWindow.WndProc(Message&)
at
JetBrains.ReSharper.TextControl.VSIntegration.Windows.VsEditorParentWindow.WndProc(Message&)
in
c:\TEMP\tmpABD0.tmp\src\VSIntegration\src\TextControl\Windows\VsEditorParentWindow.cs:line
47 column 11
at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr,
IntPtr)

0
Comment actions Permalink

Hello Pablo,

Thank you for your patience. I was able to reproduce the problem. Sorry for
a delay - I've tested it on a wrong build.
The insertion of an alias directive is a bug. We will fix it ASAP. The tracker
link for the bug is http://www.intellij.net/tracker/resharper/viewSCR?publicId=9156

Thanks,
Andrey Simanovsky


0
Comment actions Permalink

BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ands@intellij.com wrote:

Hello Pablo,

Thank you for your patience. I was able to reproduce the problem. Sorry
for a delay - I've tested it on a wrong build.
The insertion of an alias directive is a bug. We will fix it ASAP. The
tracker link for the bug is
http://www.intellij.net/tracker/resharper/viewSCR?publicId=9156

Thanks,
Andrey Simanovsky

Brilliant, many thanks! =)
Pablo
-


BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDBhqXvooSiBfQCSoRAlxzAJ9sQ8dp+KbmHhOvTYUvxhGC9uh4eQCgmrjk
pvSlMCz9fLhYeIyQOy7lZO4=
=Bi8C
-


END PGP SIGNATURE-----

0

Please sign in to leave a comment.