Browse Source

Fixed SD2-1522: Exception when double-clicking in empty first line.

Fixed some FxCop issues.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3786 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
be17ca8431
  1. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs
  2. 3
      src/Main/Core/Project/Src/Services/PropertyService/Properties.cs
  3. 6
      src/Main/Core/Project/Src/Services/StringParser/StringParser.cs
  4. 2
      src/Main/ICSharpCode.SharpDevelop.BuildWorker/BuildJob.cs
  5. 17
      src/Main/ICSharpCode.SharpDevelop.BuildWorker/Program.cs
  6. 2
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Ambience.cs
  7. 52
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExpressionContext.cs
  8. 6
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/DefaultMethod.cs
  9. 6
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/DefaultProperty.cs
  10. 22
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/TypeVisitor.cs
  11. 6
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs
  12. 5
      src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs

@ -454,6 +454,8 @@ namespace ICSharpCode.TextEditor @@ -454,6 +454,8 @@ namespace ICSharpCode.TextEditor
int FindWordEnd(IDocument document, int offset)
{
LineSegment line = document.GetLineSegmentForOffset(offset);
if (line.Length == 0)
return offset;
int endPos = line.Offset + line.Length;
offset = Math.Min(offset, endPos - 1);

3
src/Main/Core/Project/Src/Services/PropertyService/Properties.cs

@ -9,6 +9,7 @@ using System; @@ -9,6 +9,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml;
@ -64,7 +65,7 @@ namespace ICSharpCode.Core @@ -64,7 +65,7 @@ namespace ICSharpCode.Core
public string this[string property] {
get {
return Convert.ToString(Get(property));
return Convert.ToString(Get(property), CultureInfo.InvariantCulture);
}
set {
Set(property, value);

6
src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

@ -100,7 +100,7 @@ namespace ICSharpCode.Core @@ -100,7 +100,7 @@ namespace ICSharpCode.Core
StringBuilder output = null; // don't use StringBuilder if input is a single property
do {
int oldPos = pos;
pos = input.IndexOf("${", pos);
pos = input.IndexOf("${", pos, StringComparison.Ordinal);
if (pos < 0) {
if (output == null) {
return input;
@ -149,7 +149,7 @@ namespace ICSharpCode.Core @@ -149,7 +149,7 @@ namespace ICSharpCode.Core
// most properties start with res: in lowercase,
// so we can save 2 string allocations here, in addition to all the jumps
// All other prefixed properties {prefix:Key} shoulg get handled in the switch below.
if (propertyName.StartsWith("res:")) {
if (propertyName.StartsWith("res:", StringComparison.OrdinalIgnoreCase)) {
try {
return Parse(ResourceService.GetString(propertyName.Substring(4)), customTags);
} catch (ResourceNotFoundException) {
@ -235,7 +235,7 @@ namespace ICSharpCode.Core @@ -235,7 +235,7 @@ namespace ICSharpCode.Core
static string GetProperty(string propertyName)
{
string defaultValue = "";
int pos = propertyName.LastIndexOf("??");
int pos = propertyName.LastIndexOf("??", StringComparison.Ordinal);
if (pos >= 0) {
defaultValue = propertyName.Substring(pos + 2);
propertyName = propertyName.Substring(0, pos);

2
src/Main/ICSharpCode.SharpDevelop.BuildWorker/BuildJob.cs

@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop.BuildWorker @@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop.BuildWorker
get { return additionalImports; }
}
HashSet<string> interestingTaskNames = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
HashSet<string> interestingTaskNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
public ICollection<string> InterestingTaskNames {
get { return interestingTaskNames; }

17
src/Main/ICSharpCode.SharpDevelop.BuildWorker/Program.cs

@ -10,12 +10,14 @@ @@ -10,12 +10,14 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization;
using System.Threading;
using ICSharpCode.SharpDevelop.BuildWorker.Interprocess;
using Microsoft.Build.Framework;
using Microsoft.Build.BuildEngine;
using Microsoft.Build.Framework;
namespace ICSharpCode.SharpDevelop.BuildWorker
{
@ -107,7 +109,8 @@ namespace ICSharpCode.SharpDevelop.BuildWorker @@ -107,7 +109,8 @@ namespace ICSharpCode.SharpDevelop.BuildWorker
}
// Called with CallMethodOnWorker
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
//[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
// TODO: make use of CancelBuild
public void CancelBuild()
{
lock (this) {
@ -442,6 +445,14 @@ namespace ICSharpCode.SharpDevelop.BuildWorker @@ -442,6 +445,14 @@ namespace ICSharpCode.SharpDevelop.BuildWorker
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic")]
sealed class BuildCancelException : Exception
{
public BuildCancelException()
{
}
BuildCancelException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}
}

2
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Ambience.cs

@ -116,7 +116,7 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -116,7 +116,7 @@ namespace ICSharpCode.SharpDevelop.Dom
{
#if DEBUG
if (ownerThread != System.Threading.Thread.CurrentThread.ManagedThreadId)
throw new Exception("Ambience may only be used by the thread that created it");
throw new InvalidOperationException("Ambience may only be used by the thread that created it");
#endif
}

52
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ExpressionContext.cs

@ -62,104 +62,104 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -62,104 +62,104 @@ namespace ICSharpCode.SharpDevelop.Dom
#region C# specific contexts (public static fields) * MOVE TO ANOTHER CLASS *
/// <summary>The context expects a new identifier</summary>
/// <example>class *expr* {}; string *expr*;</example>
public static ExpressionContext IdentifierExpected = new DefaultExpressionContext("IdentifierExpected");
public readonly static ExpressionContext IdentifierExpected = new DefaultExpressionContext("IdentifierExpected");
/// <summary>The context is outside of any type declaration, expecting a global-level keyword.</summary>
public static ExpressionContext Global = new DefaultExpressionContext("Global");
public readonly static ExpressionContext Global = new DefaultExpressionContext("Global");
/// <summary>The context is the body of a property declaration.</summary>
/// <example>string Name { *expr* }</example>
public static ExpressionContext PropertyDeclaration = new DefaultExpressionContext("PropertyDeclaration");
public readonly static ExpressionContext PropertyDeclaration = new DefaultExpressionContext("PropertyDeclaration");
/// <summary>The context is the body of a property declaration inside an interface.</summary>
/// <example>string Name { *expr* }</example>
public static ExpressionContext InterfacePropertyDeclaration = new DefaultExpressionContext("InterfacePropertyDeclaration");
public readonly static ExpressionContext InterfacePropertyDeclaration = new DefaultExpressionContext("InterfacePropertyDeclaration");
/// <summary>The context is the body of a event declaration.</summary>
/// <example>event EventHandler NameChanged { *expr* }</example>
public static ExpressionContext EventDeclaration = new DefaultExpressionContext("EventDeclaration");
public readonly static ExpressionContext EventDeclaration = new DefaultExpressionContext("EventDeclaration");
/// <summary>The context is the body of a method.</summary>
/// <example>void Main () { *expr* }</example>
public static ExpressionContext MethodBody = new DefaultExpressionContext("MethodBody");
public readonly static ExpressionContext MethodBody = new DefaultExpressionContext("MethodBody");
/// <summary>The context is after the type parameters of a type/method declaration.
/// The only valid keyword is "where"</summary>
/// <example>class &lt;T&gt; *expr*</example>
public static ExpressionContext ConstraintsStart = new DefaultExpressionContext("ConstraintsStart");
public readonly static ExpressionContext ConstraintsStart = new DefaultExpressionContext("ConstraintsStart");
/// <summary>The context is after the 'where' of a constraints list.</summary>
/// <example>class &lt;T&gt; where *expr*</example>
public static ExpressionContext Constraints = new NonStaticTypeExpressionContext("Constraints", false);
public readonly static ExpressionContext Constraints = new NonStaticTypeExpressionContext("Constraints", false);
/// <summary>The context is the body of a type declaration.</summary>
public static ExpressionContext TypeDeclaration = new NonStaticTypeExpressionContext("TypeDeclaration", true);
public readonly static ExpressionContext TypeDeclaration = new NonStaticTypeExpressionContext("TypeDeclaration", true);
/// <summary>The context is the body of an interface declaration.</summary>
public static ExpressionContext InterfaceDeclaration = new NonStaticTypeExpressionContext("InterfaceDeclaration", true);
public readonly static ExpressionContext InterfaceDeclaration = new NonStaticTypeExpressionContext("InterfaceDeclaration", true);
/// <summary>Context expects "base" or "this".</summary>
/// <example>public ClassName() : *expr*</example>
public static ExpressionContext BaseConstructorCall = new DefaultExpressionContext("BaseConstructorCall");
public readonly static ExpressionContext BaseConstructorCall = new DefaultExpressionContext("BaseConstructorCall");
/// <summary>The first parameter</summary>
/// <example>void MethodName(*expr*)</example>
public static ExpressionContext FirstParameterType = new NonStaticTypeExpressionContext("FirstParameterType", false);
public readonly static ExpressionContext FirstParameterType = new NonStaticTypeExpressionContext("FirstParameterType", false);
/// <summary>Another parameter</summary>
/// <example>void MethodName(..., *expr*)</example>
public static ExpressionContext ParameterType = new NonStaticTypeExpressionContext("ParameterType", false);
public readonly static ExpressionContext ParameterType = new NonStaticTypeExpressionContext("ParameterType", false);
/// <summary>Context expects a fully qualified type name.</summary>
/// <example>using Alias = *expr*;</example>
public static ExpressionContext FullyQualifiedType = new DefaultExpressionContext("FullyQualifiedType");
public readonly static ExpressionContext FullyQualifiedType = new DefaultExpressionContext("FullyQualifiedType");
/// <summary>Context expects is a property name in an object initializer.</summary>
/// <example>new *type* [(args)] { *expr* = ... }</example>
public static ExpressionContext ObjectInitializer = new DefaultExpressionContext("ObjectInitializer");
public readonly static ExpressionContext ObjectInitializer = new DefaultExpressionContext("ObjectInitializer");
#endregion
#region Default contexts (public static fields)
/// <summary>Default/unknown context</summary>
public static ExpressionContext Default = new DefaultExpressionContext("Default");
public readonly static ExpressionContext Default = new DefaultExpressionContext("Default");
/// <summary>The context expects the base type of an enum.</summary>
/// <example>enum Name : *expr* {}</example>
public static ExpressionContext EnumBaseType = new EnumBaseTypeExpressionContext();
public readonly static ExpressionContext EnumBaseType = new EnumBaseTypeExpressionContext();
/// <summary>Context expects a non-sealed type or interface</summary>
/// <example>class C : *expr* {}</example>
public static ExpressionContext InheritableType = new InheritableTypeExpressionContext();
public readonly static ExpressionContext InheritableType = new InheritableTypeExpressionContext();
/// <summary>Context expects a namespace name</summary>
/// <example>using *expr*;</example>
public static ExpressionContext Namespace = new ImportableExpressionContext(false);
public readonly static ExpressionContext Namespace = new ImportableExpressionContext(false);
/// <summary>Context expects an importable type (namespace or class with public static members)</summary>
/// <example>Imports *expr*;</example>
public static ExpressionContext Importable = new ImportableExpressionContext(true);
public readonly static ExpressionContext Importable = new ImportableExpressionContext(true);
/// <summary>Context expects a type name</summary>
/// <example>typeof(*expr*)</example>
public static ExpressionContext Type = new TypeExpressionContext(null, false, true);
public readonly static ExpressionContext Type = new TypeExpressionContext(null, false, true);
/// <summary>Context expects the name of a non-static, non-void type</summary>
/// <example>is *expr*, *expr* variableName</example>
public static ExpressionContext NonStaticNonVoidType = new NonStaticTypeExpressionContext("NonStaticType", false);
public readonly static ExpressionContext NonStaticNonVoidType = new NonStaticTypeExpressionContext("NonStaticType", false);
/// <summary>Context expects a non-abstract type that has accessible constructors</summary>
/// <example>new *expr*();</example>
/// <remarks>When using this context, a resolver should treat the expression as object creation,
/// even when the keyword "new" is not part of the expression.</remarks>
public static ExpressionContext ObjectCreation = new TypeExpressionContext(null, true, true);
public readonly static ExpressionContext ObjectCreation = new TypeExpressionContext(null, true, true);
/// <summary>Context expects a type deriving from System.Attribute.</summary>
/// <example>[*expr*()]</example>
/// <remarks>When using this context, a resolver should try resolving typenames with an
/// appended "Attribute" suffix and treat "invocations" of the attribute type as
/// object creation.</remarks>
public static ExpressionContext Attribute = new AttributeExpressionContext();
public readonly static ExpressionContext Attribute = new AttributeExpressionContext();
/// <summary>Context expects a type name which has special base type</summary>
/// <param name="baseClass">The class the expression must derive from.</param>
@ -173,11 +173,11 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -173,11 +173,11 @@ namespace ICSharpCode.SharpDevelop.Dom
/// <summary>Context expects an interface</summary>
/// <example>interface C : *expr* {}</example>
/// <example>Implements *expr*</example>
public static ExpressionContext Interface = new ClassTypeExpressionContext(ClassType.Interface);
public readonly static ExpressionContext Interface = new ClassTypeExpressionContext(ClassType.Interface);
/// <summary>Context expects a delegate</summary>
/// <example>public event *expr*</example>
public static ExpressionContext DelegateType = new ClassTypeExpressionContext(ClassType.Delegate);
public readonly static ExpressionContext DelegateType = new ClassTypeExpressionContext(ClassType.Delegate);
#endregion

6
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/DefaultMethod.cs

@ -195,14 +195,10 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -195,14 +195,10 @@ namespace ICSharpCode.SharpDevelop.Dom
public virtual int CompareTo(IMethod value)
{
int cmp;
if (FullyQualifiedName != null) {
cmp = FullyQualifiedName.CompareTo(value.FullyQualifiedName);
int cmp = string.CompareOrdinal(this.FullyQualifiedName, value.FullyQualifiedName);
if (cmp != 0) {
return cmp;
}
}
cmp = this.TypeParameters.Count - value.TypeParameters.Count;
if (cmp != 0) {

6
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Implementations/DefaultProperty.cs

@ -138,14 +138,10 @@ namespace ICSharpCode.SharpDevelop.Dom { @@ -138,14 +138,10 @@ namespace ICSharpCode.SharpDevelop.Dom {
public virtual int CompareTo(IProperty value)
{
int cmp;
if (FullyQualifiedName != null) {
cmp = FullyQualifiedName.CompareTo(value.FullyQualifiedName);
int cmp = string.CompareOrdinal(this.FullyQualifiedName, value.FullyQualifiedName);
if (cmp != 0) {
return cmp;
}
}
return DiffUtility.Compare(Parameters, value.Parameters);
}

22
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/TypeVisitor.cs

@ -70,8 +70,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -70,8 +70,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
break;
}
}
if (t == null && callingMember is IMethod && (callingMember as IMethod).TypeParameters != null) {
foreach (ITypeParameter tp in (callingMember as IMethod).TypeParameters) {
IMethod callingMethod = callingMember as IMethod;
if (t == null && callingMethod != null) {
foreach (ITypeParameter tp in callingMethod.TypeParameters) {
if (languageProperties.NameComparer.Equals(tp.Name, reference.Type)) {
t = new GenericReturnType(tp);
break;
@ -80,18 +81,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -80,18 +81,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
}
if (t == null) {
if (reference.IsKeyword && reference.GenericTypes.Count == 0) {
int typeParameterCount = reference.GenericTypes.Count;
if (reference.IsKeyword) {
// keyword-type like void, int, string etc.
// check GenericTypes.Count to prevent use of this code path for nullables
IClass c = projectContent.GetClass(reference.Type, 0);
IClass c = projectContent.GetClass(reference.Type, typeParameterCount);
if (c != null)
t = c.DefaultReturnType;
else
t = new GetClassReturnType(projectContent, reference.Type, 0);
t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
} else {
int typeParameterCount = reference.GenericTypes.Count;
if (useLazyReturnType || isBaseTypeReference) {
if (reference.IsGlobal || reference.IsKeyword) {
if (reference.IsGlobal) {
t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
} else if (callingClass != null) {
SearchClassReturnType scrt = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.Type, typeParameterCount);
@ -101,7 +101,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -101,7 +101,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
} else {
IClass c;
if (reference.IsGlobal || reference.IsKeyword) {
if (reference.IsGlobal) {
c = projectContent.GetClass(reference.Type, typeParameterCount);
t = (c != null) ? c.DefaultReturnType : null;
} else if (callingClass != null) {
@ -114,9 +114,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver @@ -114,9 +114,9 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver
}
}
if (reference.GenericTypes.Count > 0) {
List<IReturnType> para = new List<IReturnType>(reference.GenericTypes.Count);
IReturnType[] para = new IReturnType[reference.GenericTypes.Count];
for (int i = 0; i < reference.GenericTypes.Count; ++i) {
para.Add(CreateReturnType(reference.GenericTypes[i], callingClass, callingMember, caretLine, caretColumn, projectContent, options));
para[i] = CreateReturnType(reference.GenericTypes[i], callingClass, callingMember, caretLine, caretColumn, projectContent, options);
}
t = new ConstructedReturnType(t, para);
}

6
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/Refactoring/NRefactoryRefactoringProvider.cs

@ -608,12 +608,14 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring @@ -608,12 +608,14 @@ namespace ICSharpCode.SharpDevelop.Dom.Refactoring
static bool IsEndDirective(string trimLine)
{
return trimLine.StartsWith("#endregion") || trimLine.StartsWith("#endif");
return trimLine.StartsWith("#endregion", StringComparison.Ordinal)
|| trimLine.StartsWith("#endif", StringComparison.Ordinal);
}
static bool IsStartDirective(string trimLine)
{
return trimLine.StartsWith("#region") || trimLine.StartsWith("#if");
return trimLine.StartsWith("#region", StringComparison.Ordinal)
|| trimLine.StartsWith("#if", StringComparison.Ordinal);
}
#endregion
}

5
src/Main/ICSharpCode.SharpDevelop.Sda/Src/ExceptionBox.cs

@ -155,11 +155,12 @@ namespace ICSharpCode.SharpDevelop.Sda @@ -155,11 +155,12 @@ namespace ICSharpCode.SharpDevelop.Sda
void CopyInfoToClipboard()
{
if (copyErrorCheckBox.Checked) {
string exceptionText = exceptionTextBox.Text;
if (Application.OleRequired() == ApartmentState.STA) {
ClipboardWrapper.SetText(getClipboardString());
ClipboardWrapper.SetText(exceptionText);
} else {
Thread th = new Thread((ThreadStart)delegate {
ClipboardWrapper.SetText(getClipboardString());
ClipboardWrapper.SetText(exceptionText);
});
th.Name = "CopyInfoToClipboard";
th.SetApartmentState(ApartmentState.STA);

Loading…
Cancel
Save