Skip to content

Commit 2b55aeb

Browse files
author
tbulle
committed
Merge branch 'master' of github.com:gumme/SharpDevelop
2 parents 6f7ebb5 + 3759d08 commit 2b55aeb

File tree

85 files changed

+1289
-1049
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1289
-1049
lines changed
-17.9 KB
Binary file not shown.
-177 KB
Binary file not shown.

src/AddIns/Analysis/CodeQuality/Gui/MainView.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System;
2020
using System.Collections.Generic;
2121
using System.Collections.ObjectModel;
22+
using System.IO;
2223
using System.Windows;
2324
using System.Windows.Controls;
2425

@@ -72,7 +73,7 @@ void AddCurrentProjectAssemblyClick(object sender, RoutedEventArgs e)
7273
return;
7374

7475
string fileName = ProjectService.CurrentProject.OutputAssemblyFullPath;
75-
if (string.IsNullOrEmpty(fileName))
76+
if (!File.Exists(fileName))
7677
{
7778
MessageBox.Show("Project output assembly not found! Please build it first!");
7879
return;

src/AddIns/BackendBindings/CSharpBinding/Project/Src/CaretReferenceHighlightRenderer.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public void Dispose()
7979
public void Draw(TextView textView, DrawingContext drawingContext)
8080
{
8181
if (currentReferences == null) {
82+
if (textView.VisualLines.Count == 0)
83+
return;
8284
var start = textView.VisualLines.First().FirstDocumentLine.LineNumber;
8385
var end = textView.VisualLines.Last().LastDocumentLine.LineNumber;
8486
currentReferences = new List<ISegment>();
@@ -188,7 +190,7 @@ void ColorizeMatch(AstNode node, ResolveResult result)
188190
{
189191
var identifierNode = FindReferences.GetNodeToReplace(node);
190192
TextLocation start, end;
191-
if (!identifierNode.IsNull) {
193+
if (identifierNode != null && !identifierNode.IsNull) {
192194
start = identifierNode.StartLocation;
193195
end = identifierNode.EndLocation;
194196
}

src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ void InsertWithCursorOnLayer(EditorScript currentScript, InsertionCursorLayer la
152152
if (doc != null) {
153153
doc.UndoStack.Push(op);
154154
}
155+
layer.ScrollToInsertionPoint();
155156
layer.Exited += delegate(object s, InsertionCursorEventArgs args) {
156157
doc.UndoStack.StartContinuedUndoGroup();
157158
try {

src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/InsertionCursorLayer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public InsertionCursorLayer(TextArea editor, string operation, IList<InsertionPo
6565
this.editor.TextView.InsertLayer(this, KnownLayer.Text, LayerInsertionPosition.Above);
6666
this.editor.TextView.ScrollOffsetChanged += TextViewScrollOffsetChanged;
6767
AddGroupBox();
68-
ScrollToInsertionPoint();
6968
}
7069

7170
static readonly Pen markerPen = new Pen(Brushes.Blue, 2);
@@ -246,7 +245,7 @@ void InsertCode(object sender, ExecutedRoutedEventArgs e)
246245
FireExited(true);
247246
}
248247

249-
void ScrollToInsertionPoint()
248+
internal void ScrollToInsertionPoint()
250249
{
251250
var location = insertionPoints[CurrentInsertionPoint].Location;
252251
editor.GetService<TextEditor>().ScrollTo(location.Line, location.Column);

src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/IssueManager.cs

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ Task<IContextAction[]> IContextActionProvider.GetAvailableActionsAsync(EditorRef
345345
result.AddRange(tag.Actions);
346346
string issueName;
347347
if (CanSuppress(tag, out issueName)) {
348-
result.Add(new SuppressIssueContextAction(issueName, SuppressType.Once));
349-
result.Add(new SuppressIssueContextAction(issueName, SuppressType.Always));
348+
result.Add(new SuppressIssueContextAction(issueName));
350349
}
351350
}
352351
}
@@ -363,21 +362,14 @@ bool CanSuppress(InspectionTag tag, out string issueName)
363362
return true;
364363
}
365364

366-
enum SuppressType {
367-
Once,
368-
Always
369-
}
370-
371365
[ContextAction("Suppress issue", Description = "Suppresses an issue.")]
372366
class SuppressIssueContextAction : ContextAction
373367
{
374368
string issueName;
375-
SuppressType type;
376369

377-
public SuppressIssueContextAction(string issueName, SuppressType type)
370+
public SuppressIssueContextAction(string issueName)
378371
{
379372
this.issueName = issueName;
380-
this.type = type;
381373
}
382374

383375
public override Task<bool> IsAvailableAsync(EditorRefactoringContext context, CancellationToken cancellationToken)
@@ -387,27 +379,21 @@ public override Task<bool> IsAvailableAsync(EditorRefactoringContext context, Ca
387379

388380
public override string DisplayName
389381
{
390-
get {
391-
string fmt;
392-
if (type == SuppressType.Once)
393-
fmt = "Suppress '{0}' once";
394-
else
395-
fmt = "Suppress '{0}'";
396-
return string.Format(fmt, issueName);
397-
}
382+
get { return string.Format("Suppress '{0}'", issueName); }
398383
}
399384

400385
public override void Execute(EditorRefactoringContext context)
401386
{
402-
var myContext = SDRefactoringContext.Create(context.Editor, default(CancellationToken));
403-
var currentNode = myContext.RootNode.GetNodeAt<Statement>(context.CaretLocation);
404-
if (currentNode == null)
405-
return;
406-
using (var script = myContext.StartScript()) {
407-
script.InsertBefore(currentNode, new Comment(string.Format(" disable{1}{0}", issueName, type == SuppressType.Once ? " once " : " ")));
408-
}
387+
SD.AnalyticsMonitor.TrackFeature(typeof(SuppressIssueContextAction), issueName);
388+
var lineNo = context.CaretLocation.Line;
389+
var document = context.Editor.Document;
390+
391+
var line = document.GetLineByNumber(lineNo);
392+
string indentation = DocumentUtilities.GetIndentation(document, lineNo);
393+
string newLine = DocumentUtilities.GetLineTerminator(document, lineNo);
394+
document.Insert(line.Offset, indentation + "// disable once " + issueName + newLine);
409395
}
410396
}
411-
#endregion
412397
}
398+
#endregion
413399
}

src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ClipboardRingAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ClipboardRingAction : IContextAction
2424

2525
public ClipboardRingAction(string text)
2626
{
27-
string entry = text.Trim();
27+
string entry = System.Text.RegularExpressions.Regex.Replace(text.Trim(), @"\s+", " ");
2828
if(entry.Length > maxLength)
2929
entry = entry.Substring(0, maxLength-endString.Length) + endString;
3030

src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ public void ShowHelp()
510510

511511
void LoadAndDisplayDesigner()
512512
{
513+
SD.AnalyticsMonitor.TrackFeature(typeof(FormsDesignerViewContent), "Load");
513514
try {
514515

515516
LoadDesigner();
@@ -627,6 +628,7 @@ static string FormatLoadErrors(DesignSurface designSurface)
627628

628629
public virtual void MergeFormChanges()
629630
{
631+
SD.AnalyticsMonitor.TrackFeature(typeof(FormsDesignerViewContent), "Save");
630632
if (this.HasLoadError || this.designSurface == null) {
631633
LoggingService.Debug("Forms designer: Cannot merge form changes because the designer is not loaded successfully or not loaded at all");
632634
return;

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
8484
{
8585
wasChangedInDesigner = false;
8686
Debug.Assert(file == this.PrimaryFile);
87+
SD.AnalyticsMonitor.TrackFeature(typeof(WpfViewContent), "Load");
8788

8889
_stream = new MemoryStream();
8990
stream.CopyTo(_stream);
@@ -137,6 +138,7 @@ protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
137138
protected override void SaveInternal(OpenedFile file, System.IO.Stream stream)
138139
{
139140
if (wasChangedInDesigner && designer.DesignContext != null) {
141+
SD.AnalyticsMonitor.TrackFeature(typeof(WpfViewContent), "Save");
140142
XmlWriterSettings settings = new XmlWriterSettings();
141143
settings.Indent = true;
142144
settings.IndentChars = SD.EditorControlService.GlobalOptions.IndentationString;

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
3030
/// Provides <see cref="IPlacementBehavior"/> behavior for <see cref="Canvas"/>.
3131
/// </summary>
3232
[ExtensionFor(typeof(Canvas), OverrideExtension=typeof(DefaultPlacementBehavior))]
33-
public sealed class CanvasPlacementSupport : SnaplinePlacementBehavior
33+
public class CanvasPlacementSupport : SnaplinePlacementBehavior
3434
{
3535
GrayOutDesignerExceptActiveArea grayOut;
36+
FrameworkElement extendedComponent;
37+
FrameworkElement extendedView;
3638

3739
static double GetCanvasProperty(UIElement element, DependencyProperty d)
3840
{
@@ -48,6 +50,14 @@ static bool IsPropertySet(UIElement element, DependencyProperty d)
4850
return element.ReadLocalValue(d) != DependencyProperty.UnsetValue;
4951
}
5052

53+
protected override void OnInitialized()
54+
{
55+
base.OnInitialized();
56+
57+
extendedComponent = (FrameworkElement)ExtendedItem.Component;
58+
extendedView = (FrameworkElement)this.ExtendedItem.View;
59+
}
60+
5161
public override void SetPosition(PlacementInformation info)
5262
{
5363
base.SetPosition(info);
@@ -58,7 +68,7 @@ public override void SetPosition(PlacementInformation info)
5868

5969
if (IsPropertySet(child, Canvas.RightProperty))
6070
{
61-
var newR = ((Canvas) ExtendedItem.Component).ActualWidth - newPosition.Right;
71+
var newR = extendedComponent.ActualWidth - newPosition.Right;
6272
if (newR != GetCanvasProperty(child, Canvas.RightProperty))
6373
info.Item.Properties.GetAttachedProperty(Canvas.RightProperty).SetValue(newR);
6474
}
@@ -70,7 +80,7 @@ public override void SetPosition(PlacementInformation info)
7080

7181
if (IsPropertySet(child, Canvas.BottomProperty))
7282
{
73-
var newB = ((Canvas)ExtendedItem.Component).ActualHeight - newPosition.Bottom;
83+
var newB = extendedComponent.ActualHeight - newPosition.Bottom;
7484
if (newB != GetCanvasProperty(child, Canvas.BottomProperty))
7585
info.Item.Properties.GetAttachedProperty(Canvas.BottomProperty).SetValue(newB);
7686
}
@@ -81,8 +91,7 @@ public override void SetPosition(PlacementInformation info)
8191

8292
if (info.Item == Services.Selection.PrimarySelection)
8393
{
84-
var cv = this.ExtendedItem.View as Canvas;
85-
var b = new Rect(0, 0, cv.ActualWidth, cv.ActualHeight);
94+
var b = new Rect(0, 0, extendedView.ActualWidth, extendedView.ActualHeight);
8695
// only for primary selection:
8796
if (grayOut != null)
8897
{

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/ExampleService.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,25 @@ protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
6767
// TODO: add this test, check for correct setting of NameScope
6868
//TestHelperLog.Log("ExampleDependencyObject.OnPropertyChanged " + e.Property.Name);
6969
}
70+
71+
public static readonly DependencyProperty ExampleProperty = DependencyProperty.RegisterAttached(
72+
"Example", typeof(string), typeof(ExampleDependencyObject)
73+
);
74+
75+
public static string GetExample(DependencyObject element)
76+
{
77+
TestHelperLog.Log("ExampleDependencyObject.GetExample");
78+
return (string)element.GetValue(ExampleProperty);
79+
}
80+
81+
public static void SetExample(DependencyObject element, string value)
82+
{
83+
TestHelperLog.Log("ExampleDependencyObject.SetExample");
84+
element.SetValue(ExampleProperty, value);
85+
}
86+
}
87+
88+
public class DerivedExampleDependencyObject : ExampleDependencyObject
89+
{
7090
}
7191
}

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,5 +418,18 @@ public void ExampleClassObjectPropWithExplicitMarkupExtension2()
418418
</t:ExampleClass>
419419
");
420420
}
421+
422+
[Test]
423+
public void UsingAttachedPropertyOnDerivedClass()
424+
{
425+
TestLoading(@"
426+
<Window
427+
xmlns=""http://schemas.microsoft.com/netfx/2007/xaml/presentation""
428+
xmlns:t=""" + XamlTypeFinderTests.XamlDomTestsNamespace + @"""
429+
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
430+
t:DerivedExampleDependencyObject.Example=""test"">
431+
</Window>
432+
");
433+
}
421434
}
422435
}

src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,11 @@ internal static XamlPropertyInfo TryFindAttachedProperty(Type elementType, strin
478478
return new XamlDependencyPropertyInfo((DependencyProperty)field.GetValue(null), true);
479479
}
480480
}
481+
482+
if (elementType.BaseType != null) {
483+
return TryFindAttachedProperty(elementType.BaseType, propertyName);
484+
}
485+
481486
return null;
482487
}
483488

src/AddIns/DisplayBindings/XmlEditor/Project/Src/RunXslTransformCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public override void Run()
5858

5959
if (xmlView.StylesheetFileName != null) {
6060
try {
61-
xmlView.RunXslTransform(GetStylesheetContent(xmlView.StylesheetFileName));
61+
xmlView.RunXslTransform(GetStylesheetContent(xmlView.StylesheetFileName), xmlView.StylesheetFileName);
6262
} catch (Exception ex) {
6363
MessageService.ShowException(ex);
6464
}

src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static void DisplayValidationWarning(string fileName, string message, int column
461461
/// <summary>
462462
/// Applys the stylesheet to the xml and displays the resulting output.
463463
/// </summary>
464-
public void RunXslTransform(string xsl)
464+
public void RunXslTransform(string xsl, string transformFileName)
465465
{
466466
try {
467467
SD.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
@@ -472,9 +472,9 @@ public void RunXslTransform(string xsl)
472472
if (editor == null) return;
473473

474474
if (IsWellFormed) {
475-
if (IsValidXsl(xsl)) {
475+
if (IsValidXsl(xsl, transformFileName)) {
476476
try {
477-
string transformedXml = Transform(editor.Document.Text, xsl);
477+
string transformedXml = Transform(editor.Document.Text, xsl, transformFileName);
478478
ShowTransformOutput(transformedXml);
479479
} catch (XsltException ex) {
480480
AddTask(GetFileNameFromInnerException(ex, StylesheetFileName), GetInnerExceptionErrorMessage(ex), ex.LineNumber, ex.LinePosition, TaskType.Error);
@@ -507,7 +507,7 @@ void ShowTransformOutput(string xml)
507507
/// <param name="input">The input xml to transform.</param>
508508
/// <param name="transform">The transform xml.</param>
509509
/// <returns>The output of the transform.</returns>
510-
static string Transform(string input, string transform)
510+
static string Transform(string input, string transform, string transformFileName)
511511
{
512512
StringReader inputString = new StringReader(input);
513513
XmlTextReader sourceDocument = new XmlTextReader(inputString);
@@ -516,7 +516,7 @@ static string Transform(string input, string transform)
516516
XPathDocument transformDocument = new XPathDocument(transformString);
517517

518518
XslCompiledTransform xslTransform = new XslCompiledTransform();
519-
xslTransform.Load(transformDocument, XsltSettings.TrustedXslt, new XmlUrlResolver());
519+
xslTransform.Load(transformDocument, XsltSettings.TrustedXslt, new XslTransformUrlResolver(transformFileName));
520520

521521
MemoryStream outputStream = new MemoryStream();
522522
XmlTextWriter writer = new XmlTextWriter(outputStream, Encoding.UTF8);
@@ -531,7 +531,7 @@ static string Transform(string input, string transform)
531531
/// <summary>
532532
/// Validates the given xsl string,.
533533
/// </summary>
534-
bool IsValidXsl(string xml)
534+
bool IsValidXsl(string xml, string transformFileName)
535535
{
536536
try {
537537
SD.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
@@ -540,13 +540,13 @@ bool IsValidXsl(string xml)
540540
XPathDocument doc = new XPathDocument(reader);
541541

542542
XslCompiledTransform xslTransform = new XslCompiledTransform();
543-
xslTransform.Load(doc, XsltSettings.Default, new XmlUrlResolver());
543+
xslTransform.Load(doc, XsltSettings.Default, new XslTransformUrlResolver(transformFileName));
544544

545545
return true;
546546
} catch(XsltCompileException ex) {
547547
AddTask(StylesheetFileName, GetInnerExceptionErrorMessage(ex), ex.LineNumber, ex.LinePosition, TaskType.Error);
548548
} catch(XsltException ex) {
549-
AddTask(StylesheetFileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskType.Error);
549+
AddTask(StylesheetFileName, GetInnerExceptionErrorMessage(ex), ex.LinePosition, ex.LineNumber, TaskType.Error);
550550
} catch(XmlException ex) {
551551
AddTask(StylesheetFileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskType.Error);
552552
}

0 commit comments

Comments
 (0)