Skip to content

Commit

Permalink
Updating for v4.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr committed Dec 10, 2018
2 parents 92714de + 2ffa27f commit f51e835
Show file tree
Hide file tree
Showing 13 changed files with 389 additions and 312 deletions.
392 changes: 200 additions & 192 deletions src/Viasfora.Core/Text/KeywordTagger.cs

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions src/Viasfora.Core/Text/KeywordTaggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
using Microsoft.VisualStudio.Utilities;
using Winterdom.Viasfora.Tags;
using Winterdom.Viasfora.Languages;

using System.Threading.Tasks;

namespace Winterdom.Viasfora.Text {

[Export(typeof(IViewTaggerProvider))]
Expand Down Expand Up @@ -97,14 +98,24 @@ private void FixItalics() {
}
} finally {
this.formatMap.EndBatchUpdate();
this.working = false;
// If we change the formats, the corresponding
// format map update event could fire just after we leave
// this block, causing cascading calls.
// To avoid this, delay resetting the working flag
// until after some small time has passed.
Task.Delay(500).ContinueWith(
(parentTask) => this.working = false
);
}
}

private void SetItalics(IClassificationType classifierType, bool enable) {
var tp = this.formatMap.GetTextProperties(classifierType);

tp = tp.SetItalic(enable);
this.formatMap.SetTextProperties(classifierType, tp);
if ( !tp.Italic ) {
tp = tp.SetItalic(enable);
this.formatMap.SetTextProperties(classifierType, tp);
}
}
}
}
3 changes: 3 additions & 0 deletions src/Viasfora.Core/Viasfora.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
Expand Down
30 changes: 28 additions & 2 deletions src/Viasfora.Languages/BraceScanners/CSharpBraceScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class CSharpBraceScanner : IBraceScanner, IResumeControl {

private int status = stText;
private int nestingLevel = 0;
private int istringNestLevel = 0;
private bool parsingExpression = false;
private bool multiLine = false;

Expand All @@ -26,6 +27,7 @@ public void Reset(int state) {
this.parsingExpression = (state & 0x08000000) != 0;
this.nestingLevel = (state & 0xFF0000) >> 24;
this.multiLine = (state & 0x04000000) != 0;
this.istringNestLevel = (state & 0xFF00) >> 16;
}

public bool CanResume(CharPos brace) {
Expand Down Expand Up @@ -168,7 +170,23 @@ private bool ParseInterpolatedString(ITextChars tc, ref CharPos pos) {
//
// we're inside an interpolated section
//
if ( tc.Char() == '"' ) {
if ( tc.Char() == '$' && tc.NChar() == '"' ) {
// opening nested interpolated string
tc.Skip(2);
this.parsingExpression = false;
this.istringNestLevel++;
this.nestingLevel = 0;
if ( this.ParseInterpolatedString(tc, ref pos) )
return true;
this.istringNestLevel--;
this.parsingExpression = true;
this.status = stIString;
} else if ( tc.Char() == '@' && tc.NChar() == '"' ) {
// opening nested verbatim string
tc.Skip(2);
this.ParseMultiLineString(tc);
this.status = stIString;
} else if ( tc.Char() == '"' ) {
// opening string
tc.Next();
this.ParseString(tc);
Expand Down Expand Up @@ -216,8 +234,15 @@ private bool ParseInterpolatedString(ITextChars tc, ref CharPos pos) {
tc.Skip(2);
} else if ( tc.Char() == '"' ) {
// done parsing the interpolated string
this.status = stText;
this.multiLine = false;
this.istringNestLevel--;
if (this.istringNestLevel <= 0) {
this.istringNestLevel = 0;
this.status = stText;
} else {
this.status = stIString;
this.parsingExpression = true;
}
tc.Next();
break;
} else {
Expand All @@ -235,6 +260,7 @@ private int EncodedState() {
if ( this.multiLine )
encoded |= 0x04000000;
encoded |= (this.nestingLevel & 0xFF) << 24;
encoded |= (this.istringNestLevel & 0xFF) << 16;
return encoded;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Viasfora.Languages/Cpp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Winterdom.Viasfora.Languages {
[Export(typeof(ILanguage))]
class Cpp : CBasedLanguage, ILanguage {
private readonly static String[] knownTypes =
new String[] { "C/C++", "HLSL" };
new String[] { "C/C++", "HLSL", "C/C++ (VisualGDB)" };

protected override String[] SupportedContentTypes
=> knownTypes;
Expand Down
6 changes: 6 additions & 0 deletions src/Viasfora.Languages/Viasfora.Languages.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '14.0' ">
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
Expand Down
11 changes: 10 additions & 1 deletion src/Viasfora.Rainbow/RainbowLines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,17 @@ private double CalculateLeftOfFirstChar(SnapshotPoint open, IFormattedLineSource
var line = open.GetContainingLine();
var x = 0d;
var start = line.Start;
int spacesSinceLastTab = 0;
while ( Char.IsWhiteSpace(start.GetChar()) ) {
x += start.GetChar() == '\t' ? fls.TabSize * fls.ColumnWidth : fls.ColumnWidth;
char ch = start.GetChar();
if ( ch == ' ' ) {
spacesSinceLastTab = ++spacesSinceLastTab % fls.TabSize;
x += fls.ColumnWidth;
} else if ( ch == '\t' ) {
x += ((fls.TabSize - spacesSinceLastTab) * fls.ColumnWidth);
spacesSinceLastTab = 0;
}
//x += start.GetChar() == '\t' ? fls.TabSize * fls.ColumnWidth : fls.ColumnWidth;
start = start + 1;
}
return x;
Expand Down
3 changes: 3 additions & 0 deletions src/Viasfora.Rainbow/Viasfora.Rainbow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>False</EmbedInteropTypes>
Expand Down
3 changes: 3 additions & 0 deletions src/Viasfora.Xml/Viasfora.Xml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
Expand Down
208 changes: 103 additions & 105 deletions src/Viasfora/Telemetry.cs
Original file line number Diff line number Diff line change
@@ -1,108 +1,106 @@
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;

namespace Winterdom.Viasfora {
public class Telemetry {
private TelemetryClient client;
public bool Enabled { get; private set; }

public Telemetry(bool enabled, EnvDTE80.DTE2 dte = null) {
TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();

this.client = new TelemetryClient(config);
this.client.InstrumentationKey = "b59d19eb-668d-4ae3-b4c8-71536ebabbdc";

this.client.Context.User.Id = GetUserId();
this.client.Context.Session.Id = Guid.NewGuid().ToString();
this.client.Context.Properties.Add("Host", dte.Application.Edition);
this.client.Context.Properties.Add("HostVersion", dte.Version);
this.client.Context.Properties.Add("HostFullVersion", GetFullHostVersion());
this.client.Context.Component.Version = GetViasforaVersion();
this.client.Context.Properties.Add("AppVersion", GetFullHostVersion());
this.client.Context.Device.OperatingSystem = Environment.OSVersion.ToString();

using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;

namespace Winterdom.Viasfora {
public class Telemetry {
private TelemetryClient client;
public bool Enabled { get; private set; }

public Telemetry(bool enabled, EnvDTE80.DTE2 dte = null) {
TelemetryConfiguration config = TelemetryConfiguration.CreateDefault();

this.client = new TelemetryClient(config);
this.client.InstrumentationKey = "b59d19eb-668d-4ae3-b4c8-71536ebabbdc";

this.client.Context.User.Id = GetUserId();
this.client.Context.Session.Id = Guid.NewGuid().ToString();
this.client.Context.Properties.Add("Host", "VS");
this.client.Context.Properties.Add("HostVersion", dte.Version);
this.client.Context.Properties.Add("HostFullVersion", GetFullHostVersion());
this.client.Context.Component.Version = GetViasforaVersion();

if (enabled && dte != null) {
dte.Events.DTEEvents.OnBeginShutdown += OnBeginShutdown;
}

Enabled = enabled;

WriteEvent("Viasfora Started");
}

public void WriteEvent(String eventName) {
#if !DEBUG
if ( this.client != null && Enabled ) {
this.client.TrackEvent(new EventTelemetry(eventName));
}
#endif
}

public void WriteEvent(EventTelemetry evt) {
#if !DEBUG
if ( this.client != null && Enabled ) {
this.client.TrackEvent(evt);
}
#endif
}

public void WriteException(String msg, Exception ex) {
#if !DEBUG
if ( this.client != null && Enabled ) {
ExceptionTelemetry telemetry = new ExceptionTelemetry(ex);
telemetry.Properties.Add("Message", msg);
this.client.TrackException(telemetry);
}
#endif
}

public void WriteTrace(String message) {
#if !DEBUG
if ( this.client != null && Enabled ) {
this.client.TrackTrace(message);
}
#endif
}

private void OnBeginShutdown() {
this.client.Flush();
}

private static String GetFullHostVersion() {
try {
String baseDir = AppDomain.CurrentDomain.BaseDirectory;
String devenv = Path.Combine(baseDir, "msenv.dll");
var version = FileVersionInfo.GetVersionInfo(devenv);
return version.ProductVersion;
} catch {
// Ignore if we cannot get
}
return "";
}

private static String GetViasforaVersion() {
var assembly = typeof(Telemetry).Assembly;
var fileVersion = assembly
.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)
.Cast<AssemblyFileVersionAttribute>()
.First().Version;
return fileVersion;
}

private static String GetUserId() {
var user = Environment.MachineName + "\\" + Environment.UserName;
var bytes = Encoding.UTF8.GetBytes(user);
using ( var sha = SHA256.Create() ) {
return Convert.ToBase64String(sha.ComputeHash(bytes));
}
}
}
}

Enabled = enabled;

WriteEvent("Viasfora Started");
}

public void WriteEvent(String eventName) {
#if !DEBUG
if ( this.client != null && Enabled ) {
this.client.TrackEvent(new EventTelemetry(eventName));
}
#endif
}

public void WriteEvent(EventTelemetry evt) {
#if !DEBUG
if ( this.client != null && Enabled ) {
this.client.TrackEvent(evt);
}
#endif
}

public void WriteException(String msg, Exception ex) {
#if !DEBUG
if ( this.client != null && Enabled ) {
ExceptionTelemetry telemetry = new ExceptionTelemetry(ex);
telemetry.Properties.Add("Message", msg);
this.client.TrackException(telemetry);
}
#endif
}

public void WriteTrace(String message) {
#if !DEBUG
if ( this.client != null && Enabled ) {
this.client.TrackTrace(message);
}
#endif
}

private void OnBeginShutdown() {
this.client.Flush();
}

private static String GetFullHostVersion() {
try {
String baseDir = AppDomain.CurrentDomain.BaseDirectory;
String devenv = Path.Combine(baseDir, "msenv.dll");
var version = FileVersionInfo.GetVersionInfo(devenv);
return version.ProductVersion;
} catch {
// Ignore if we cannot get
}
return "";
}

private static String GetViasforaVersion() {
var assembly = typeof(Telemetry).Assembly;
var fileVersion = assembly
.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)
.Cast<AssemblyFileVersionAttribute>()
.First().Version;
return fileVersion;
}

private static String GetUserId() {
var user = Environment.MachineName + "\\" + Environment.UserName;
var bytes = Encoding.UTF8.GetBytes(user);
using ( var sha = SHA256.Create() ) {
return Convert.ToBase64String(sha.ComputeHash(bytes));
}
}
}
}
3 changes: 3 additions & 0 deletions src/Viasfora/Viasfora.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '15.0' ">
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '16.0' ">
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
Expand Down
Loading

0 comments on commit f51e835

Please sign in to comment.