MihailRomanov / SharpDevelop

#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
7 stars 3 forks source link

Double clicking added control gives exception #30

Open jeff-pf opened 3 months ago

jeff-pf commented 3 months ago

After adding a control to the form- when double clicked to add code gives the following exception.

Unhandled WPF exception Exception thrown: System.ArgumentOutOfRangeException: 0 <= offset <= 3115 Parameter name: offset Actual value was 3130. at ICSharpCode.AvalonEdit.Document.TextDocument.GetLineByOffset(Int32 offset) at ICSharpCode.AvalonEdit.Document.TextDocument.GetLocation(Int32 offset) at ICSharpCode.SharpDevelop.NRefactory.Wrappers.DocumentWrapper.GetLocation(Int32 offset) at ICSharpCode.NRefactory.CSharp.Refactoring.DocumentScript.FormatText(IEnumerable`1 nodes) at ICSharpCode.NRefactory.CSharp.Refactoring.DocumentScript.Dispose() at CSharpBinding.Refactoring.EditorScript.DisposeOnClose(Boolean force) at CSharpBinding.Refactoring.EditorScript.Dispose() at CSharpBinding.Refactoring.CSharpCodeGenerator.InsertEventHandler(ITypeDefinition target, String name, IEvent eventDefinition, Boolean jumpTo, InsertEventHandlerBodyKind bodyKind) at CSharpBinding.FormsDesigner.CSharpEventBindingService.InsertEventHandlerInternal(String methodName, IEvent evt) at CSharpBinding.FormsDesigner.CSharpEventBindingService.<>c__DisplayClass10_1.b__0() at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

MihailRomanov commented 2 weeks ago

@jeff-pf Unfortunatelly I can't reproduce your situation. What I do:

As result - created new event handler in code behinde file (button1_Click).

I encountered a similar issue (Exception in language parser) when I translated the SD into the new AvalonEditor (from NuGet). But I thought I fixed it

Couould you add some details:

May be you can add simple sample project, where it reproduced?

P.S. I apologize for answering with such a great delay - there is no time at all to deal with the project, although there is a great desire. Thank you for your understanding

jeff-pf commented 2 weeks ago

No worries on the timing. The bug was actually a Windows Application - Windows Application (not WPF). I just tested a WPF project and I do NOT see the bug there.

I can also reproduce on multiple windows 10 machines. I can reproduce it with a new project or existing project. Here is the version info that has the bug - beta 2.

SharpDevelop Version : 5.2.0.5275-Beta 2-ba175761 .NET Version : 4.8.03761 OS Version : Microsoft Windows NT 6.3.9600.0 Current culture : English (United States) (en-US) Running under WOW6432, processor architecture: x86-64 Working Set Memory : 163224kb GC Heap Memory : 23094kb

The issue does not exist in this beta version

SharpDevelop Version : 5.2.0.5261-Beta-6b34077e .NET Version : 4.8.09037 OS Version : Microsoft Windows NT 6.3.9600.0 Current culture : English (United States) (en-US) Running under WOW6432, processor architecture: x86-64 Working Set Memory : 118724kb GC Heap Memory : 11001kb

Since the 5.2.1 version works good for my use this bug is not a big deal for me - just thought doing some testing would help SD go forward.

Thanks for taking a look at it.

MihailRomanov commented 2 weeks ago

@jeff-pf Thank you very much!! Yes, I was able to reproduce it - everything is very clearly manifested.

This is definitely a bug introduced by switching to NRefactory and AvalonEditor from different NuGet packages that were made in beta2.

Alas, my knowledge of the inner workings of SharpDevelop is still clearly not enough, and the tests, unfortunately, do not cover everything.

I will figure it out. Thank you again!