Browse Source

fixed small, but annoying bugs in VB Lexer and profiler

pull/21/merge
Siegfried Pammer 14 years ago
parent
commit
cf9a06642b
  1. 18
      src/AddIns/Analysis/Profiler/Controller/Data/PerformanceCounterDescriptor.cs
  2. 3
      src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs

18
src/AddIns/Analysis/Profiler/Controller/Data/PerformanceCounterDescriptor.cs

@ -97,15 +97,19 @@ namespace ICSharpCode.Profiler.Controller.Data
/// </summary> /// </summary>
public static string GetProcessInstanceName(int pid) public static string GetProcessInstanceName(int pid)
{ {
PerformanceCounterCategory cat = new PerformanceCounterCategory("Process"); try {
PerformanceCounterCategory cat = new PerformanceCounterCategory("Process");
string[] instances = cat.GetInstanceNames(); string[] instances = cat.GetInstanceNames();
foreach (string instance in instances) { foreach (string instance in instances) {
using (PerformanceCounter procIdCounter = new PerformanceCounter("Process", "ID Process", instance, true)) { using (PerformanceCounter procIdCounter = new PerformanceCounter("Process", "ID Process", instance, true)) {
int val = (int)procIdCounter.RawValue; int val = (int)procIdCounter.RawValue;
if (val == pid) if (val == pid)
return instance; return instance;
}
} }
} catch (Exception) {
return null;
} }
return null; return null;

3
src/Libraries/NRefactory/Project/Src/Lexer/VBNet/Lexer.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
char ch = (char)nextChar; char ch = (char)nextChar;
#region XML mode #region XML mode
CheckXMLState(startLocation); CheckXMLState(startLocation);
if (inXmlMode && xmlModeStack.Peek().level <= 0 && !xmlModeStack.Peek().isDocumentStart && !xmlModeStack.Peek().inXmlTag) { if (inXmlMode && xmlModeStack.Count > 0 && xmlModeStack.Peek().level <= 0 && !xmlModeStack.Peek().isDocumentStart && !xmlModeStack.Peek().inXmlTag) {
XmlModeInfo info = xmlModeStack.Peek(); XmlModeInfo info = xmlModeStack.Peek();
int peek = nextChar; int peek = nextChar;
while (true) { while (true) {
@ -361,6 +361,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
} }
} }
[Conditional("DEBUG")]
void CheckXMLState(Location startLocation) void CheckXMLState(Location startLocation)
{ {
if (inXmlMode && !xmlModeStack.Any()) if (inXmlMode && !xmlModeStack.Any())

Loading…
Cancel
Save