Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Common/Product/SharedProject/DesignPropertyDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ public override object GetEditor(Type editorBaseType) {
public override TypeConverter Converter {
get {
if (converter == null) {
if (converter == null) {
converter = property.Converter;
}
converter = property.Converter;
}
return converter;
}
Expand Down
2 changes: 1 addition & 1 deletion Common/Product/SharedProject/Navigation/ModuleId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override int GetHashCode() {

public override bool Equals(object obj) {
ModuleId other = obj as ModuleId;
if (null == obj) {
if (null == other) {
return false;
}
if (!_ownerHierarchy.Equals(other._ownerHierarchy)) {
Expand Down
2 changes: 1 addition & 1 deletion Common/Product/SharedProject/Navigation/SourceLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public int Column {
public static int Compare(SourceLocation left, SourceLocation right) {
if (left < right)
return -1;
if (right > left)
if (left > right)
return 1;

return 0;
Expand Down
3 changes: 1 addition & 2 deletions Common/Product/SharedProject/ProjectNode.CopyPaste.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ public int Drop(IOleDataObject pDataObject, uint grfKeyState, uint itemid, ref u

int returnValue;
try {
DropDataType dropDataType = DropDataType.None;
pdwEffect = (uint)QueryDropEffect(grfKeyState);
dropDataType = ProcessSelectionDataObject(pDataObject, targetNode, true, (DropEffect)pdwEffect);
DropDataType dropDataType = ProcessSelectionDataObject(pDataObject, targetNode, true, (DropEffect)pdwEffect);
if (dropDataType == DropDataType.None) {
pdwEffect = (uint)DropEffect.None;
}
Expand Down
12 changes: 4 additions & 8 deletions Common/Product/SharedProject/ProjectNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2678,16 +2678,13 @@ protected int CanOverwriteExistingItem(string originalFileName, string computedN
return VSConstants.E_INVALIDARG;
}

string message = String.Empty;
string title = String.Empty;
OLEMSGICON icon = OLEMSGICON.OLEMSGICON_CRITICAL;
OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_OK;
OLEMSGDEFBUTTON defaultButton = OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST;

// File already exists in project... message box
message = SR.GetString(inProject ? SR.FileAlreadyInProject : SR.FileAlreadyExists, Path.GetFileName(computedNewFileName));
icon = OLEMSGICON.OLEMSGICON_QUERY;
buttons = OLEMSGBUTTON.OLEMSGBUTTON_YESNO;
string message = SR.GetString(inProject ? SR.FileAlreadyInProject : SR.FileAlreadyExists, Path.GetFileName(computedNewFileName));
OLEMSGICON icon = OLEMSGICON.OLEMSGICON_QUERY;
OLEMSGBUTTON buttons = OLEMSGBUTTON.OLEMSGBUTTON_YESNO;
int msgboxResult = Utilities.ShowMessageBox(this.Site, title, message, icon, buttons, defaultButton);
if (msgboxResult == NativeMethods.IDCANCEL) {
return (int)E_CANCEL_FILE_ADD;
Expand Down Expand Up @@ -4569,9 +4566,8 @@ public virtual int AddComponent(VSADDCOMPOPERATION dwAddCompOperation, uint cCom
return VSConstants.E_NOTIMPL;
}
for (int cCount = 0; cCount < cComponents; cCount++) {
VSCOMPONENTSELECTORDATA selectorData = new VSCOMPONENTSELECTORDATA();
IntPtr ptr = rgpcsdComponents[cCount];
selectorData = (VSCOMPONENTSELECTORDATA)Marshal.PtrToStructure(ptr, typeof(VSCOMPONENTSELECTORDATA));
VSCOMPONENTSELECTORDATA selectorData = (VSCOMPONENTSELECTORDATA)Marshal.PtrToStructure(ptr, typeof(VSCOMPONENTSELECTORDATA));
if (null == references.AddReferenceFromSelectorData(selectorData)) {
//Skip further proccessing since a reference has to be added
pResult[0] = VSADDCOMPRESULT.ADDCOMPRESULT_Failure;
Expand Down
2 changes: 1 addition & 1 deletion Nodejs/Product/Analysis/JavaScript/SourceLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public int Column
public static int Compare(SourceLocation left, SourceLocation right)
{
if (left < right) return -1;
if (right > left) return 1;
if (left > right) return 1;

return 0;
}
Expand Down
4 changes: 1 addition & 3 deletions Nodejs/Product/Nodejs/Debugger/DebugEngine/AD7Thread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,10 @@ int IDebugThread100.GetFlags(out uint flags) {
}

int IDebugThread100.GetThreadProperties100(uint dwFields, THREADPROPERTIES100[] props) {
int hRes = VSConstants.S_OK;

// Invoke GetThreadProperties to get the VS7/8/9 properties
THREADPROPERTIES[] props90 = new THREADPROPERTIES[1];
enum_THREADPROPERTY_FIELDS dwFields90 = (enum_THREADPROPERTY_FIELDS)(dwFields & 0x3f);
hRes = ((IDebugThread2)this).GetThreadProperties(dwFields90, props90);
int hRes = ((IDebugThread2)this).GetThreadProperties(dwFields90, props90);
props[0].bstrLocation = props90[0].bstrLocation;
props[0].bstrName = props90[0].bstrName;
props[0].bstrPriority = props90[0].bstrPriority;
Expand Down
2 changes: 1 addition & 1 deletion Nodejs/Product/Npm/SPI/NpmBinCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public string BinDirectory {
if (null == _binDirectory) {
var temp = StandardOutput;
if (null != temp) {
temp.Trim();
temp = temp.Trim();
if (temp.Length > 0) {
// The standard output contains an informational
// message added by the base command class through
Expand Down
7 changes: 2 additions & 5 deletions Nodejs/Product/Npm/sqlite/SQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2091,9 +2091,8 @@ public int ExecuteNonQuery ()
Debug.WriteLine ("Executing: " + this);
}

var r = SQLite3.Result.OK;
var stmt = Prepare ();
r = SQLite3.Step (stmt);
var r = SQLite3.Step (stmt);
Finalize (stmt);
if (r == SQLite3.Result.Done) {
int rowsAffected = SQLite3.Changes (_conn.Handle);
Expand Down Expand Up @@ -2400,8 +2399,6 @@ public int ExecuteNonQuery (object[] source)
Debug.WriteLine ("Executing: " + CommandText);
}

var r = SQLite3.Result.OK;

if (!Initialized) {
Statement = Prepare ();
Initialized = true;
Expand All @@ -2413,7 +2410,7 @@ public int ExecuteNonQuery (object[] source)
SQLiteCommand.BindParameter (Statement, i + 1, source [i], Connection.StoreDateTimeAsTicks);
}
}
r = SQLite3.Step (Statement);
var r = SQLite3.Step (Statement);

if (r == SQLite3.Result.Done) {
int rowsAffected = SQLite3.Changes (Connection.Handle);
Expand Down
2 changes: 1 addition & 1 deletion Nodejs/Product/Profiling/Profiling/StandaloneTargetView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void StandaloneTargetView_PropertyChanged(object sender, PropertyChangedEventArg
WorkingDirectory.IndexOfAny(Path.GetInvalidPathChars()) == -1 &&
(Path.IsPathRooted(ScriptPath) || Path.IsPathRooted(WorkingDirectory)) &&
File.Exists(Path.Combine(WorkingDirectory, ScriptPath)) &&
(string.IsNullOrEmpty(WorkingDirectory) || Directory.Exists(WorkingDirectory)) &&
(WorkingDirectory == string.Empty || Directory.Exists(WorkingDirectory)) &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behavior and some analyzers will complain about comparing to string.Empty directly. Is there a specific reason for this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use WorkingDirectory at the line 152, before check it for null. So I can suppose that check is not needed. Maybe NullReferenceException is possible at the line 152. Maybe we should check it for null before using.

(File.Exists(InterpreterPath));
}
}
Expand Down
25 changes: 11 additions & 14 deletions Nodejs/Product/ReferenceGenerator/ReferenceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
//*********************************************************//
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Xml;
using Microsoft.NodejsTools;
Expand Down Expand Up @@ -190,7 +187,7 @@ private void GenerateModuleWorker(dynamic module, int indentation, string name)
case "join": body = ReferenceCode.PathJoinBody; break;
}
}
GenerateMethod(name, method, indentation + 1, body);
GenerateMethod(method, indentation + 1, body);
}
}

Expand All @@ -200,7 +197,7 @@ private void GenerateModuleWorker(dynamic module, int indentation, string name)

if (module.ContainsKey("classes")) {
foreach (var klass in module["classes"]) {
GenerateClass(name, klass, indentation + 1);
GenerateClass(klass, indentation + 1);
}
}

Expand All @@ -210,7 +207,7 @@ private void GenerateModuleWorker(dynamic module, int indentation, string name)
GenerateProperties(module["properties"], indentation + 1, specializer);
}

_output.AppendFormat("}}", name);
_output.Append("}}");
}

private Dictionary<string, Func<string, string>> PropertySpecializations = MakePropertySpecializations();
Expand Down Expand Up @@ -242,15 +239,15 @@ private static string ProcessPropertySpecialization(string propertyName) {
return null;
}

private void GenerateClass(string modName, dynamic klass, int indentation) {
private void GenerateClass(dynamic klass, int indentation) {
string className = FixClassName(klass["name"]);
_output.Append(' ', indentation * 4);
_output.AppendFormat("function _{0}() {{", className);
_output.AppendLine();

if (klass.ContainsKey("methods")) {
foreach (var method in klass["methods"]) {
GenerateMethod(modName + "." + className, method, indentation + 1);
GenerateMethod(method, indentation + 1);
}
}

Expand Down Expand Up @@ -294,13 +291,13 @@ private void GenerateProperties(dynamic properties, int indentation, Func<string

_output.Append(' ', indentation * 4);
string value = null;
if (desc.IndexOf("<code>Boolean</code>") != -1) {
if (desc.IndexOf("<code>Boolean</code>", StringComparison.Ordinal) != -1) {
value = "true";
} else if (desc.IndexOf("<code>Number</code>") != -1) {
} else if (desc.IndexOf("<code>Number</code>", StringComparison.Ordinal) != -1) {
value = "0";
} else if (desc.IndexOf("<code>Readable Stream</code>") != -1) {
} else if (desc.IndexOf("<code>Readable Stream</code>", StringComparison.Ordinal) != -1) {
value = "require('stream').Readable()";
} else if (desc.IndexOf("<code>Writable Stream</code>") != -1 || textRaw == "process.stderr") {
} else if (desc.IndexOf("<code>Writable Stream</code>", StringComparison.Ordinal) != -1 || textRaw == "process.stderr") {
value = "require('stream').Writable()";
} else if (!String.IsNullOrWhiteSpace(textRaw)) {
int start, end;
Expand Down Expand Up @@ -394,7 +391,7 @@ private void GenerateEvents(dynamic events, int indentation) {
_output.AppendLine("}");
}

private void GenerateMethod(string fullName, dynamic method, int indentation, string body = null) {
private void GenerateMethod(dynamic method, int indentation, string body = null) {
_output.Append(' ', indentation * 4);
_output.AppendFormat("this.{0} = function(", method["name"]);
var signature = method["signatures"][0];
Expand Down Expand Up @@ -475,7 +472,7 @@ private void GenerateMethod(string fullName, dynamic method, int indentation, st
_output.AppendLine(body);
} else if (method["name"].StartsWith("create") && method["name"].Length > 6) {
_output.Append(' ', indentation * 4);
_output.AppendFormat("return new this.{1}();", fullName, method["name"].Substring(6));
_output.AppendFormat("return new this.{0}();", method["name"].Substring(6));
_output.AppendLine();
}
_output.Append(' ', indentation * 4);
Expand Down
4 changes: 1 addition & 3 deletions Nodejs/Tests/NpmTests/NpmSearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ private void CheckPackage(
private IList<IPackage> GetTestPackageList(
string cachePath,
out IDictionary<string, IPackage> byName) {
IList<IPackage> target = new List<IPackage>();

target = new NpmGetCatalogCommand(string.Empty, cachePath, false, RegistryUrl).GetCatalogPackagesAsync(string.Empty, new Uri(RegistryUrl)).GetAwaiter().GetResult().ToList();
IList<IPackage> target = new NpmGetCatalogCommand(string.Empty, cachePath, false, RegistryUrl).GetCatalogPackagesAsync(string.Empty, new Uri(RegistryUrl)).GetAwaiter().GetResult().ToList();

// Do this after because package names can be split across multiple
// lines and therefore may change after the IPackage is initially created.
Expand Down