提交 0ece11c9 编写于 作者: J Jared Parsons 提交者: GitHub

Merge pull request #12426 from jaredpar/sqm

Remove SQM depedency from the compiler
......@@ -111,7 +111,6 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
bool reportAnalyzer = false;
CultureInfo preferredUILang = null;
string touchedFilesPath = null;
var sqmSessionGuid = Guid.Empty;
bool optionsEnded = false;
bool interactiveMode = false;
bool publicSign = false;
......@@ -305,12 +304,15 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
continue;
case "sqmsessionguid":
// The use of SQM is deprecated in the compiler but we still support the parsing of the option for
// back compat reasons.
if (value == null)
{
AddDiagnostic(diagnostics, ErrorCode.ERR_MissingGuidForOption, "<text>", name);
}
else
{
Guid sqmSessionGuid;
if (!Guid.TryParse(value, out sqmSessionGuid))
{
AddDiagnostic(diagnostics, ErrorCode.ERR_InvalidFormatForGuidForOption, value, name);
......@@ -1228,7 +1230,6 @@ public new CSharpCommandLineArguments Parse(IEnumerable<string> args, string bas
PrintFullPaths = printFullPaths,
ShouldIncludeErrorEndLocation = errorEndLocation,
PreferredUILang = preferredUILang,
SqmSessionGuid = sqmSessionGuid,
ReportAnalyzer = reportAnalyzer
};
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
///////////////////////////////////////////////////////////////////////////////
//
// IVsSqm.cs : Interop definitions for interfaces defined in VsLog.idl
//
///////////////////////////////////////////////////////////////////////////////
#pragma warning disable 3001
namespace Microsoft.VisualStudio.Shell.Interop
{
using System;
using System.Runtime.InteropServices;
[ComImport()]
[ComVisible(false)]
[Guid("C1F63D0C-4CAE-4907-BE74-EEB75D386ECB")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSqm
{
void GetSessionStartTime(
[Out] out System.Runtime.InteropServices.ComTypes.FILETIME time
);
void GetFlags(
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 flags
);
void SetFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 flags
);
void ClearFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 flags
);
void AddItemToStream(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
// OBSOLETE IN SQMAPI.DLL. DO NOT CALL.
void GetDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 value
);
void EnterTaggedAssert(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dwTag,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dwPossibleBuild,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dwActualBuild
);
void RecordCmdData(
[In] ref Guid pguidCmdGroup,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void GetHashOfGuid(
[In] ref Guid hashGuid,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 resultantHash
);
void GetHashOfString(
[In, MarshalAs(UnmanagedType.BStr)] string hashString,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 resultantHash
);
void IncrementDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointBits(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointIfMax(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointIfMin(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddToDatapointAverage(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void StartDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void RecordDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AccumulateDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AddTimerToDatapointAverage(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AddArrayToStream(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U4, SizeParamIndex = 2)] System.UInt32[] data,
[In, MarshalAs(UnmanagedType.I4)] int count
);
}
[ComImport()]
[ComVisible(false)]
[Guid("BE5F55EB-F02D-4217-BCB6-A290800AF6C4")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSqm2
{
void SetBoolDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 fValue
);
void SetStringDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.BStr)] string strValue
);
void AddToStreamDWord(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 cTuple,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddToStreamString(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 cTuple,
[In, MarshalAs(UnmanagedType.BStr)] string strValue
);
void GetObfuscatedString(
[In, MarshalAs(UnmanagedType.BStr)] string input,
[Out, MarshalAs(UnmanagedType.BStr)] out string output
);
}
[ComImport()]
[ComVisible(false)]
[Guid("B17A7D4A-C1A3-45A2-B916-826C3ABA067E")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSqmMulti
{
[return: MarshalAs(UnmanagedType.VariantBool)]
bool GetOptInStatus();
void UnloadSessions(
);
void EndAllSessionsAndAbortUploads(
);
void BeginSession(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionType,
[In, MarshalAs(UnmanagedType.VariantBool)] System.Boolean alwaysSend,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 sessionHandle
);
void EndSession(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle
);
void RegisterSessionHandle(
[In] ref Guid sessionIdentifier,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dwSessionHandle
);
[return: MarshalAs(UnmanagedType.U4)]
int GetSessionHandleByIdentifier(
[In] ref Guid sessionIdentifier
);
void GetSessionStartTime(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[Out] out System.Runtime.InteropServices.ComTypes.FILETIME time
);
Guid GetGlobalSessionGuid();
[return: MarshalAs(UnmanagedType.U4)]
int GetGlobalSessionHandle();
void SetGlobalSessionGuid(
[In] ref Guid pguidSessionGuid
);
void GetFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 flags
);
void SetFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 flags
);
void ClearFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 flags
);
void SetDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetBoolDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 fValue
);
void SetStringDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.BStr)] string strValue
);
void SetDatapointBits(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void IncrementDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointIfMax(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointIfMin(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddToDatapointAverage(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void StartDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void RecordDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AccumulateDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AddTimerToDatapointAverage(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AddItemToStream(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddArrayToStream(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U4, SizeParamIndex = 2)] System.UInt32[] data,
[In, MarshalAs(UnmanagedType.I4)] int count
);
void AddToStreamDWord(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 cTuple,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddToStreamString(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 cTuple,
[In, MarshalAs(UnmanagedType.BStr)] string strValue
);
void RecordCmdData(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In] ref Guid pguidCmdGroup,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void GetHashOfGuid(
[In] ref Guid hashGuid,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 resultantHash
);
void GetHashOfString(
[In, MarshalAs(UnmanagedType.BStr)] string hashString,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 resultantHash
);
void SetProperty(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 propid,
[In] ref Guid varKey,
[In] object varValue
);
void Get64BitHashOfString(
[In, MarshalAs(UnmanagedType.BStr)] string hashString,
[Out, MarshalAs(UnmanagedType.U8)] out System.UInt64 resultantHash
);
}
[ComImport()]
[ComVisible(false)]
[Guid("16be4288-950b-4265-b0dc-280b89ca9979")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSqmOptinManager
{
void GetOptinStatus(
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 optinStatus,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 preferences
);
void SetOptinStatus(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 optinStatus
);
}
[ComImport()]
[ComVisible(false)]
[Guid("2508FDF0-EF80-4366-878E-C9F024B8D981")]
internal interface SVsLog
{
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.VisualStudio.Shell.Interop;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace Microsoft.VisualStudio.Shell.Interop
{
internal static class SqmServiceProvider
{
public enum CompilerType
{
Compiler = 0,
CompilerServer = 1,
Interactive = 2
}
// SQM Constants ----- these are NOT FINAL --- real ones will be assigned when approved by VS telemetry team
public const uint CSHARP_APPID = 50u;
public const uint BASIC_APPID = 51u;
public const uint DATAID_SQM_ROSLYN_COMPILERTYPE = 1354u; // 0=Compiler, 1= CompilerServer, 2=Interactive
public const uint DATAID_SQM_BUILDVERSION = 1353u; // Roslyn Build Version
public const uint DATAID_SQM_ROSLYN_SOURCES = 1360u; // No of source code files this compile
public const uint DATAID_SQM_ROSLYN_REFERENCES = 1359u; // No of referenced assemblies this compile
public const uint DATAID_SQM_ROSLYN_ERRORNUMBERS = 1356u; // List of errors [and warnings as errors]
public const uint DATAID_SQM_ROSLYN_WARNINGNUMBERS = 1366u; // List of warnings [excluding wanings as errors]
public const uint DATAID_SQM_ROSLYN_WARNINGLEVEL = 1365u; // -warn:n 0 - 4
public const uint DATAID_SQM_ROSLYN_WARNINGASERRORS = 1364u; // -warnaserror[+/-]
public const uint DATAID_SQM_ROSLYN_SUPPRESSWARNINGNUMBERS = 1361u; // -nowarn:blah;blah;blah
public const uint DATAID_SQM_ROSLYN_WARNASERRORS_NUMBERS = 1362u; // -warnaserror+:blah;blah;blah
public const uint DATAID_SQM_ROSLYN_WARNASWARNINGS_NUMBERS = 1363u; // -warnaserror-:blah;blah;blah
public const uint DATAID_SQM_ROSLYN_OUTPUTKIND = 1358u; // /target:exe|winexe ... [ConsoleApplication = 0, WindowsApplication = 1, DynamicallyLinkedLibrary = 2, NetModule = 3, WindowsRuntimeMetadata = 4]
public const uint DATAID_SQM_ROSLYN_LANGUAGEVERSION = 1357u;
public const uint DATAID_SQM_ROSLYN_EMBEDVBCORE = 1355u;
[DllImport("vssqmmulti.dll", SetLastError = true)]
private static extern void QueryService(ref Guid rsid, ref Guid riid, out IVsSqmMulti vssqm);
public static IVsSqmMulti TryGetSqmService()
{
IVsSqmMulti result = null;
Guid rsid = new Guid("2508FDF0-EF80-4366-878E-C9F024B8D981");
Guid riid = new Guid("B17A7D4A-C1A3-45A2-B916-826C3ABA067E");
try
{
QueryService(ref rsid, ref riid, out result);
}
catch (Exception e)
{
Debug.Assert(false, string.Format("Could not get SQM service or have SQM related errors: {0}", e.ToString()));
return null;
}
return result;
}
}
}
......@@ -407,7 +407,6 @@
<Compile Include="InternalUtilities\WeakReferenceExtensions.cs" />
<Compile Include="InternalUtilities\XmlUtilities.cs" />
<Compile Include="Interop\ClrStrongName.cs" />
<Compile Include="Interop\IVsSQM.cs" />
<Compile Include="MemberDescriptor.cs" />
<Compile Include="MetadataReader\EmbeddedResource.cs" />
<Compile Include="MetadataReader\LocalSlotConstraints.cs" />
......@@ -463,7 +462,6 @@
<Compile Include="RuleSet\RuleSetInclude.cs" />
<Compile Include="RuleSet\RuleSetProcessor.cs" />
<Compile Include="SourceFileResolver.cs" />
<Compile Include="SqmServiceProvider.cs" />
<Compile Include="SymbolDisplay\ObjectDisplayExtensions.cs" />
<Compile Include="SymbolDisplay\ObjectDisplayOptions.cs" />
<Compile Include="Optional.cs" />
......
......@@ -246,8 +246,6 @@ public CompilationOptions CompilationOptions
/// </summary>
public CultureInfo PreferredUILang { get; internal set; }
internal Guid SqmSessionGuid { get; set; }
internal CommandLineArguments()
{
}
......
......@@ -12,7 +12,6 @@
using System.Threading;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis
......@@ -38,9 +37,7 @@ internal abstract partial class CommonCompiler
public abstract void PrintHelp(TextWriter consoleOutput);
internal abstract string GetToolName();
protected abstract uint GetSqmAppID();
protected abstract bool TryGetCompilerDiagnosticCode(string diagnosticId, out uint code);
protected abstract void CompilerSpecificSqm(IVsSqmMulti sqm, uint sqmSession);
protected abstract ImmutableArray<DiagnosticAnalyzer> ResolveAnalyzersFromArguments(
List<DiagnosticInfo> diagnostics,
CommonMessageProvider messageProvider);
......@@ -541,8 +538,6 @@ internal int RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, Cancella
}
var compileAndEmitDiagnostics = diagnosticBag.ToReadOnly();
GenerateSqmData(Arguments.CompilationOptions, compileAndEmitDiagnostics);
if (ReportErrors(compileAndEmitDiagnostics, consoleOutput, errorLogger))
{
return Failed;
......@@ -711,86 +706,6 @@ private static void ReportAnalyzerExecutionTime(TextWriter consoleOutput, Analyz
}
}
private void GenerateSqmData(CompilationOptions compilationOptions, ImmutableArray<Diagnostic> diagnostics)
{
// Generate SQM data file for Compilers
if (Arguments.SqmSessionGuid != Guid.Empty)
{
IVsSqmMulti sqm = null;
uint sqmSession = 0u;
try
{
sqm = SqmServiceProvider.TryGetSqmService(_clientDirectory);
if (sqm != null)
{
sqm.BeginSession(this.GetSqmAppID(), false, out sqmSession);
sqm.SetGlobalSessionGuid(Arguments.SqmSessionGuid);
// Build Version
sqm.SetStringDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_BUILDVERSION, GetAssemblyFileVersion());
// Write Errors and Warnings from build
foreach (var diagnostic in diagnostics)
{
switch (diagnostic.Severity)
{
case DiagnosticSeverity.Error:
sqm.AddItemToStream(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_ERRORNUMBERS, (uint)diagnostic.Code);
break;
case DiagnosticSeverity.Warning:
sqm.AddItemToStream(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNINGNUMBERS, (uint)diagnostic.Code);
break;
case DiagnosticSeverity.Hidden:
case DiagnosticSeverity.Info:
break;
default:
throw ExceptionUtilities.UnexpectedValue(diagnostic.Severity);
}
}
//Suppress Warnings / warningCode as error / warningCode as warning
foreach (var item in compilationOptions.SpecificDiagnosticOptions)
{
uint code;
if (TryGetCompilerDiagnosticCode(item.Key, out code))
{
ReportDiagnostic options = item.Value;
switch (options)
{
case ReportDiagnostic.Suppress:
sqm.AddItemToStream(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_SUPPRESSWARNINGNUMBERS, code); // Suppress warning
break;
case ReportDiagnostic.Error:
sqm.AddItemToStream(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNASERRORS_NUMBERS, code); // Warning as errors
break;
case ReportDiagnostic.Warn:
sqm.AddItemToStream(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNASWARNINGS_NUMBERS, code); // Warning as warnings
break;
default:
break;
}
}
}
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_OUTPUTKIND, (uint)compilationOptions.OutputKind);
CompilerSpecificSqm(sqm, sqmSession);
}
}
finally
{
if (sqm != null)
{
sqm.EndSession(sqmSession);
}
}
}
}
/// <summary>
/// Given a compilation and a destination directory, determine three names:
/// 1) The name with which the assembly should be output (default = null, which indicates that the compilation output name should be used).
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
///////////////////////////////////////////////////////////////////////////////
//
//
///////////////////////////////////////////////////////////////////////////////
#pragma warning disable 3001
using System;
using System.Runtime.InteropServices;
namespace Microsoft.VisualStudio.Shell.Interop
{
[ComImport()]
[ComVisible(false)]
[Guid("C1F63D0C-4CAE-4907-BE74-EEB75D386ECB")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSqm
{
void GetSessionStartTime(
[Out] out System.Runtime.InteropServices.ComTypes.FILETIME time
);
void GetFlags(
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 flags
);
void SetFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 flags
);
void ClearFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 flags
);
void AddItemToStream(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
// OBSOLETE IN SQMAPI.DLL. DO NOT CALL.
void GetDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 value
);
void EnterTaggedAssert(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dwTag,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dwPossibleBuild,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dwActualBuild
);
void RecordCmdData(
[In] ref Guid pguidCmdGroup,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void GetHashOfGuid(
[In] ref Guid hashGuid,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 resultantHash
);
void GetHashOfString(
[In, MarshalAs(UnmanagedType.BStr)] string hashString,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 resultantHash
);
void IncrementDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointBits(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointIfMax(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointIfMin(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddToDatapointAverage(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void StartDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void RecordDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AccumulateDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AddTimerToDatapointAverage(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AddArrayToStream(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U4, SizeParamIndex = 2)] System.UInt32[] data,
[In, MarshalAs(UnmanagedType.I4)] int count
);
}
[ComImport()]
[ComVisible(false)]
[Guid("BE5F55EB-F02D-4217-BCB6-A290800AF6C4")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSqm2
{
void SetBoolDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 fValue
);
void SetStringDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.BStr)] string strValue
);
void AddToStreamDWord(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 cTuple,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddToStreamString(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 cTuple,
[In, MarshalAs(UnmanagedType.BStr)] string strValue
);
void GetObfuscatedString(
[In, MarshalAs(UnmanagedType.BStr)] string input,
[Out, MarshalAs(UnmanagedType.BStr)] out string output
);
}
[ComImport()]
[ComVisible(false)]
[Guid("B17A7D4A-C1A3-45A2-B916-826C3ABA067E")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSqmMulti
{
[return: MarshalAs(UnmanagedType.VariantBool)]
bool GetOptInStatus();
void UnloadSessions(
);
void EndAllSessionsAndAbortUploads(
);
void BeginSession(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionType,
[In, MarshalAs(UnmanagedType.VariantBool)] System.Boolean alwaysSend,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 sessionHandle
);
void EndSession(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle
);
void RegisterSessionHandle(
[In] ref Guid sessionIdentifier,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dwSessionHandle
);
[return: MarshalAs(UnmanagedType.U4)]
int GetSessionHandleByIdentifier(
[In] ref Guid sessionIdentifier
);
void GetSessionStartTime(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[Out] out System.Runtime.InteropServices.ComTypes.FILETIME time
);
Guid GetGlobalSessionGuid();
[return: MarshalAs(UnmanagedType.U4)]
int GetGlobalSessionHandle();
void SetGlobalSessionGuid(
[In] ref Guid pguidSessionGuid
);
void GetFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 flags
);
void SetFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 flags
);
void ClearFlags(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 flags
);
void SetDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetBoolDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 fValue
);
void SetStringDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.BStr)] string strValue
);
void SetDatapointBits(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void IncrementDatapoint(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointIfMax(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void SetDatapointIfMin(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddToDatapointAverage(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void StartDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void RecordDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AccumulateDatapointTimer(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AddTimerToDatapointAverage(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID
);
void AddItemToStream(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddArrayToStream(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U4, SizeParamIndex = 2)] System.UInt32[] data,
[In, MarshalAs(UnmanagedType.I4)] int count
);
void AddToStreamDWord(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 cTuple,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void AddToStreamString(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 cTuple,
[In, MarshalAs(UnmanagedType.BStr)] string strValue
);
void RecordCmdData(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 sessionHandle,
[In] ref Guid pguidCmdGroup,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 dataPointID,
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 value
);
void GetHashOfGuid(
[In] ref Guid hashGuid,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 resultantHash
);
void GetHashOfString(
[In, MarshalAs(UnmanagedType.BStr)] string hashString,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 resultantHash
);
void SetProperty(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 propid,
[In] ref Guid varKey,
[In] object varValue
);
void Get64BitHashOfString(
[In, MarshalAs(UnmanagedType.BStr)] string hashString,
[Out, MarshalAs(UnmanagedType.U8)] out System.UInt64 resultantHash
);
}
[ComImport()]
[ComVisible(false)]
[Guid("16be4288-950b-4265-b0dc-280b89ca9979")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IVsSqmOptinManager
{
void GetOptinStatus(
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 optinStatus,
[Out, MarshalAs(UnmanagedType.U4)] out System.UInt32 preferences
);
void SetOptinStatus(
[In, MarshalAs(UnmanagedType.U4)] System.UInt32 optinStatus
);
}
[ComImport()]
[ComVisible(false)]
[Guid("2508FDF0-EF80-4366-878E-C9F024B8D981")]
internal interface SVsLog
{
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis;
namespace Microsoft.VisualStudio.Shell.Interop
{
internal static class SqmServiceProvider
{
public enum CompilerType
{
Compiler = 0,
CompilerServer = 1,
Interactive = 2
}
// SQM Constants ----- these are NOT FINAL --- real ones will be assigned when approved by VS telemetry team
public const uint CSHARP_APPID = 50u;
public const uint BASIC_APPID = 51u;
public const uint DATAID_SQM_ROSLYN_COMPILERTYPE = 1354u; // 0=Compiler, 1= CompilerServer, 2=Interactive
public const uint DATAID_SQM_BUILDVERSION = 1523u; // Roslyn Build Version
public const uint DATAID_SQM_ROSLYN_SOURCES = 1360u; // No of source code files this compile
public const uint DATAID_SQM_ROSLYN_REFERENCES = 1359u; // No of referenced assemblies this compile
public const uint DATAID_SQM_ROSLYN_ERRORNUMBERS = 1356u; // List of errors [and warnings as errors]
public const uint DATAID_SQM_ROSLYN_WARNINGNUMBERS = 1366u; // List of warnings [excluding warnings as errors]
public const uint DATAID_SQM_ROSLYN_WARNINGLEVEL = 1365u; // -warn:n 0 - 4
public const uint DATAID_SQM_ROSLYN_WARNINGASERRORS = 1364u; // -warnaserror[+/-]
public const uint DATAID_SQM_ROSLYN_SUPPRESSWARNINGNUMBERS = 1361u; // -nowarn:blah;blah;blah
public const uint DATAID_SQM_ROSLYN_WARNASERRORS_NUMBERS = 1362u; // -warnaserror+:blah;blah;blah
public const uint DATAID_SQM_ROSLYN_WARNASWARNINGS_NUMBERS = 1363u; // -warnaserror-:blah;blah;blah
public const uint DATAID_SQM_ROSLYN_OUTPUTKIND = 1358u; // /target:exe|winexe ... [ConsoleApplication = 0, WindowsApplication = 1, DynamicallyLinkedLibrary = 2, NetModule = 3, WindowsRuntimeMetadata = 4]
public const uint DATAID_SQM_ROSLYN_LANGUAGEVERSION = 1357u;
public const uint DATAID_SQM_ROSLYN_EMBEDVBCORE = 1355u;
private delegate bool QueryServiceDelegate([In]ref Guid rsid, [In]ref Guid riid, [Out]out IVsSqmMulti vssqm);
[DllImport("kernel32.dll")]
private static extern IntPtr GetProcAddress(IntPtr moduleHandle, String procName);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr LoadLibrary(String libPath);
private static Optional<QueryServiceDelegate> s_queryService;
private static readonly object s_guard = new object();
private static QueryServiceDelegate TryGetSqmServiceDelegateCore(string baseDirectory)
{
try
{
// These DLLs are only distributed with VS, they are installed to "Program Files (x86)\MSBuild\14.0\Bin".
IntPtr vssqmdll = IntPtr.Zero;
string vssqmpath;
if (IntPtr.Size == 8)
{
vssqmpath = Path.Combine(baseDirectory, @"sqmamd64\vssqmmulti.dll");
}
else
{
vssqmpath = Path.Combine(baseDirectory, @"sqmx86\vssqmmulti.dll");
}
vssqmdll = SqmServiceProvider.LoadLibrary(vssqmpath);
if (vssqmdll != IntPtr.Zero)
{
IntPtr queryServicePtr = SqmServiceProvider.GetProcAddress(vssqmdll, "QueryService");
return (QueryServiceDelegate)Marshal.GetDelegateForFunctionPointer(queryServicePtr, typeof(QueryServiceDelegate));
}
}
catch (Exception e)
{
Debug.Assert(false, string.Format("Could not get dll entry point: {0}", e.ToString()));
}
return null;
}
private static QueryServiceDelegate TryGetSqmServiceDelegate(string baseDirectory)
{
lock (s_guard)
{
if (!s_queryService.HasValue)
{
s_queryService = TryGetSqmServiceDelegateCore(baseDirectory);
}
return s_queryService.Value;
}
}
public static IVsSqmMulti TryGetSqmService(string baseDirectory)
{
IVsSqmMulti result = null;
Guid rsid = new Guid("2508FDF0-EF80-4366-878E-C9F024B8D981");
Guid riid = new Guid("B17A7D4A-C1A3-45A2-B916-826C3ABA067E");
QueryServiceDelegate queryService = TryGetSqmServiceDelegate(baseDirectory);
if (queryService != null)
{
try
{
queryService(ref rsid, ref riid, out result);
}
catch (Exception e)
{
Debug.Assert(false, string.Format("Could not get SQM service or have SQM related errors: {0}", e.ToString()));
return null;
}
}
return result;
}
}
}
......@@ -7,7 +7,6 @@
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.VisualStudio.Shell.Interop;
namespace Microsoft.CodeAnalysis.CompilerServer
{
......@@ -25,21 +24,5 @@ internal CSharpCompilerServer(Func<string, MetadataReferenceProperties, Portable
{
return _metadataProvider;
}
protected override uint GetSqmAppID()
{
return SqmServiceProvider.CSHARP_APPID;
}
protected override void CompilerSpecificSqm(IVsSqmMulti sqm, uint sqmSession)
{
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, (uint)SqmServiceProvider.CompilerType.CompilerServer);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_LANGUAGEVERSION, (uint)Arguments.ParseOptions.LanguageVersion);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNINGLEVEL, (uint)Arguments.CompilationOptions.WarningLevel);
//Project complexity # of source files, # of references
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_SOURCES, (uint)Arguments.SourceFiles.Length);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_REFERENCES, (uint)Arguments.ReferencePaths.Length);
}
}
}
......@@ -8,7 +8,6 @@
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.VisualBasic;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CompilerServer
......@@ -27,23 +26,5 @@ internal VisualBasicCompilerServer(Func<string, MetadataReferenceProperties, Por
{
return _metadataProvider;
}
protected override uint GetSqmAppID()
{
return SqmServiceProvider.BASIC_APPID;
}
protected override void CompilerSpecificSqm(IVsSqmMulti sqm, uint sqmSession)
{
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, (uint)SqmServiceProvider.CompilerType.CompilerServer);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNINGLEVEL, (uint)Arguments.CompilationOptions.WarningLevel);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_LANGUAGEVERSION, (uint)Arguments.ParseOptions.LanguageVersion);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNINGLEVEL, Arguments.CompilationOptions.GeneralDiagnosticOption == ReportDiagnostic.Suppress ? 1u : 0u);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_EMBEDVBCORE, Arguments.CompilationOptions.EmbedVbCoreRuntime ? 1u : 0u);
//Project complexity # of source files, # of references
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_SOURCES, (uint)Arguments.SourceFiles.Count());
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_REFERENCES, (uint)Arguments.ReferencePaths.Count());
}
}
}
......@@ -5,7 +5,6 @@
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
using Microsoft.CodeAnalysis.CommandLine;
......@@ -26,21 +25,5 @@ internal static int Run(string[] args, BuildPaths buildPaths, TextWriter textWri
var compiler = new Csc(responseFile, buildPaths, args, analyzerLoader);
return ConsoleUtil.RunWithUtf8Output(compiler.Arguments.Utf8Output, textWriter, tw => compiler.Run(tw));
}
protected override uint GetSqmAppID()
{
return SqmServiceProvider.CSHARP_APPID;
}
protected override void CompilerSpecificSqm(IVsSqmMulti sqm, uint sqmSession)
{
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, (uint)SqmServiceProvider.CompilerType.Compiler);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_LANGUAGEVERSION, (uint)Arguments.ParseOptions.LanguageVersion);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNINGLEVEL, (uint)Arguments.CompilationOptions.WarningLevel);
//Project complexity # of source files, # of references
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_SOURCES, (uint)Arguments.SourceFiles.Length);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_REFERENCES, (uint)Arguments.ReferencePaths.Length);
}
}
}
......@@ -3,7 +3,6 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.CodeAnalysis.CommandLine;
namespace Microsoft.CodeAnalysis.VisualBasic.CommandLine
......@@ -23,22 +22,6 @@ internal static int Run(string[] args, BuildPaths buildPaths, TextWriter textWri
var compiler = new Vbc(responseFile, buildPaths, args, analyzerLoader);
return ConsoleUtil.RunWithUtf8Output(compiler.Arguments.Utf8Output, textWriter, tw => compiler.Run(tw));
}
protected override uint GetSqmAppID()
{
return SqmServiceProvider.CSHARP_APPID;
}
protected override void CompilerSpecificSqm(IVsSqmMulti sqm, uint sqmSession)
{
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, (uint)SqmServiceProvider.CompilerType.Compiler);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_LANGUAGEVERSION, (uint)Arguments.ParseOptions.LanguageVersion);
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_WARNINGLEVEL, (uint)Arguments.CompilationOptions.WarningLevel);
//Project complexity # of source files, # of references
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_SOURCES, (uint)Arguments.SourceFiles.Count());
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_REFERENCES, (uint)Arguments.ReferencePaths.Count());
}
}
}
......@@ -6,7 +6,6 @@
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.VisualStudio.Shell.Interop;
namespace Microsoft.CodeAnalysis.CSharp.Test.Utilities
{
......@@ -26,16 +25,6 @@ public MockCSharpCompiler(string responseFile, string baseDirectory, string[] ar
_analyzers = analyzers;
}
protected override void CompilerSpecificSqm(IVsSqmMulti sqm, uint sqmSession)
{
throw new NotImplementedException();
}
protected override uint GetSqmAppID()
{
throw new NotImplementedException();
}
protected override ImmutableArray<DiagnosticAnalyzer> ResolveAnalyzersFromArguments(
List<DiagnosticInfo> diagnostics,
CommonMessageProvider messageProvider)
......
......@@ -4,7 +4,6 @@ Imports System.IO
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.VisualStudio.Shell.Interop
Friend Class MockVbi
Inherits VisualBasicCompiler
......@@ -12,12 +11,4 @@ Friend Class MockVbi
Public Sub New(responseFile As String, baseDirectory As String, args As String())
MyBase.New(VisualBasicCommandLineParser.ScriptRunner, responseFile, args, Path.GetDirectoryName(GetType(VisualBasicCompiler).Assembly.Location), baseDirectory, RuntimeEnvironment.GetRuntimeDirectory(), Nothing, New DesktopAnalyzerAssemblyLoader())
End Sub
Protected Overrides Sub CompilerSpecificSqm(sqm As IVsSqmMulti, sqmSession As UInteger)
Throw New NotImplementedException()
End Sub
Protected Overrides Function GetSqmAppID() As UInteger
Throw New NotImplementedException()
End Function
End Class
......@@ -4,7 +4,6 @@ Imports System.Collections.Immutable
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.VisualStudio.Shell.Interop
Friend Class MockVisualBasicCompiler
Inherits VisualBasicCompiler
......@@ -26,14 +25,6 @@ Friend Class MockVisualBasicCompiler
_analyzers = analyzers
End Sub
Protected Overrides Function GetSqmAppID() As UInteger
Return SqmServiceProvider.BASIC_APPID
End Function
Protected Overrides Sub CompilerSpecificSqm(sqm As IVsSqmMulti, sqmSession As UInteger)
Throw New NotImplementedException
End Sub
Protected Overrides Function ResolveAnalyzersFromArguments(
diagnostics As List(Of DiagnosticInfo),
messageProvider As CommonMessageProvider) As ImmutableArray(Of DiagnosticAnalyzer)
......
......@@ -146,7 +146,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim delaySignSetting As Boolean? = Nothing
Dim moduleAssemblyName As String = Nothing
Dim moduleName As String = Nothing
Dim sqmsessionguid As Guid = Nothing
Dim touchedFilesPath As String = Nothing
Dim features = New List(Of String)()
Dim reportAnalyzer As Boolean = False
......@@ -350,10 +349,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Continue For
Case "sqmsessionguid"
' The use of SQM is deprecated in the compiler but we still support the command line parsing for
' back compat reasons.
value = RemoveQuotesAndSlashes(value)
If String.IsNullOrWhiteSpace(value) = True Then
AddDiagnostic(diagnostics, ERRID.ERR_MissingGuidForOption, value, name)
Else
Dim sqmsessionguid As Guid
If Not Guid.TryParse(value, sqmsessionguid) Then
AddDiagnostic(diagnostics, ERRID.ERR_InvalidFormatForGuidForOption, value, name)
End If
......@@ -1332,7 +1334,6 @@ lVbRuntimePlus:
.EmitPdb = emitPdb,
.DefaultCoreLibraryReference = defaultCoreLibraryReference,
.PreferredUILang = preferredUILang,
.SqmSessionGuid = sqmsessionguid,
.ReportAnalyzer = reportAnalyzer
}
End Function
......
......@@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Scripting;
using Microsoft.CodeAnalysis.Scripting.Hosting;
using Microsoft.VisualStudio.Shell.Interop;
namespace Microsoft.CodeAnalysis.CSharp.Scripting.Hosting
{
......@@ -36,15 +35,5 @@ public override void PrintHelp(TextWriter consoleOutput)
{
consoleOutput.Write(CSharpScriptingResources.InteractiveHelp);
}
protected override uint GetSqmAppID()
{
return SqmServiceProvider.CSHARP_APPID;
}
protected override void CompilerSpecificSqm(IVsSqmMulti sqm, uint sqmSession)
{
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, (uint)SqmServiceProvider.CompilerType.Interactive);
}
}
}
......@@ -5,7 +5,6 @@ Imports System.Reflection
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Scripting.Hosting
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.VisualStudio.Shell.Interop
Namespace Microsoft.CodeAnalysis.VisualBasic.Scripting.Hosting
......@@ -30,14 +29,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Scripting.Hosting
Public Overrides Sub PrintHelp(consoleOutput As TextWriter)
consoleOutput.Write(VBScriptingResources.InteractiveHelp)
End Sub
Protected Overrides Function GetSqmAppID() As UInteger
Return SqmServiceProvider.BASIC_APPID
End Function
Protected Overrides Sub CompilerSpecificSqm(sqm As IVsSqmMulti, sqmSession As UInteger)
sqm.SetDatapoint(sqmSession, SqmServiceProvider.DATAID_SQM_ROSLYN_COMPILERTYPE, CType(SqmServiceProvider.CompilerType.Interactive, UInteger))
End Sub
End Class
End Namespace
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics;
using System.Linq;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
{
/// <summary>
/// We want to track Roslyn adoption through SQM. This datapoint
/// is used in a cube to track how many sessions are using the
/// Roslyn language services.
/// </summary>
internal static class Sqm
{
// From the V_VSAppID variable
// 38 CS VB Language Services
private const uint CS_VB_Language_Services = 38;
private const bool AlwaysSendTelemetryEvenIfUserIsOptedOut = false;
private const int DATAID_SQM_STARTUPAPPBUILDNUMBERSTRING = 780;
private const int DATAID_SQM_STARTUPAPPBUILDNUMBER = 11;
private const int DATAID_DP_PRIVATEDOGFOODBUILDNUMBER = 1437;
private const int DATAID_DP_PRIVATEBUILDNUMBER = 1438;
private const int DATAID_SQM_USERTYPE = 37;
private static int s_sqmGuidSet = 0;
public static void LogSession(IVsSqmMulti session, bool isMicrosoftInternal)
{
SetVSSessionGuid(session);
ReportVSSessionSQM(session, isMicrosoftInternal);
}
private static void SetVSSessionGuid(IVsSqmMulti session)
{
// Set the VSSessionGuid so our out-of-proc compiler builds can record sqm data
if (!(System.Threading.Interlocked.CompareExchange(ref s_sqmGuidSet, 1, 0) == 1))
{
try
{
var globalSessionGuid = session.GetGlobalSessionGuid();
// make sure we disable marking global project collection dirty before setting this global property
// otherwise, it will cause full property re-evaluation after this point since project system thinks something related
// to projects has changed.
Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.DisableMarkDirty = true;
Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.SetGlobalProperty("VSSessionGuid", globalSessionGuid.ToString());
}
finally
{
Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.DisableMarkDirty = false;
}
}
}
private static void ReportVSSessionSQM(IVsSqmMulti session, bool isMicrosoftInternal)
{
var multiSession = session;
var vsBuild = Process.GetCurrentProcess().MainModule.FileVersionInfo.ProductVersion;
var roslynBuild = FileVersionInfo.GetVersionInfo(typeof(Sqm).Assembly.Location).FileVersion;
uint sessionHandle;
multiSession.BeginSession(CS_VB_Language_Services, AlwaysSendTelemetryEvenIfUserIsOptedOut, out sessionHandle);
// Log some common datapoints useful in all cubes
multiSession.SetStringDatapoint(sessionHandle, DATAID_SQM_STARTUPAPPBUILDNUMBERSTRING, vsBuild);
LogNumericBuildNumber(multiSession, sessionHandle, DATAID_SQM_STARTUPAPPBUILDNUMBER, vsBuild);
multiSession.SetStringDatapoint(sessionHandle, DATAID_DP_PRIVATEDOGFOODBUILDNUMBER, roslynBuild);
LogNumericBuildNumber(multiSession, sessionHandle, DATAID_DP_PRIVATEBUILDNUMBER, roslynBuild);
multiSession.SetDatapoint(sessionHandle, DATAID_SQM_USERTYPE, isMicrosoftInternal ? 1u : 0);
multiSession.EndSession(sessionHandle);
}
private static void LogNumericBuildNumber(IVsSqmMulti session, uint sessionHandle, uint datapoint, string build)
{
uint numericBuild = 0;
uint.TryParse(build.Split('.').Join(""), out numericBuild);
session.SetDatapoint(sessionHandle, datapoint, numericBuild);
}
}
}
......@@ -71,15 +71,6 @@ internal abstract class VisualStudioWorkspaceImpl : VisualStudioWorkspace
// Ensure the options factory services are initialized on the UI thread
this.Services.GetService<IOptionService>();
var session = serviceProvider.GetService(typeof(SVsLog)) as IVsSqmMulti;
var profileService = serviceProvider.GetService(typeof(SVsFeedbackProfile)) as IVsFeedbackProfile;
// We have Watson hits where this came back null, so guard against it
if (profileService != null)
{
Sqm.LogSession(session, profileService.IsMicrosoftInternal);
}
}
internal static HostServices CreateHostServices(SVsServiceProvider serviceProvider)
......
......@@ -45,7 +45,6 @@
<Compile Include="..\..\..\Compilers\Core\Portable\InternalUtilities\ConcurrentLruCache.cs">
<Link>Shared\ConcurrentLruCache.cs</Link>
</Compile>
<Compile Include="..\..\..\Compilers\Core\Portable\Interop\IVsSQM.cs" />
<Compile Include="..\..\..\Compilers\Shared\ShadowCopyAnalyzerAssemblyLoader.cs">
<Link>InternalUtilities\ShadowCopyAnalyzerAssemblyLoader.cs</Link>
</Compile>
......@@ -558,7 +557,6 @@
<Compile Include="Implementation\ProjectSystem\MiscellaneousFilesWorkspace.cs" />
<Compile Include="Implementation\ProjectSystem\MiscellaneousFilesWorkspace.HostProject.cs" />
<Compile Include="Implementation\ProjectSystem\ReiteratedVersionSnapshotTracker.cs" />
<Compile Include="Implementation\ProjectSystem\Sqm.cs" />
<Compile Include="Implementation\ProjectSystem\ViewEventArgs.cs" />
<Compile Include="Implementation\ProjectSystem\VisualStudioProjectManagementService.cs" />
<Compile Include="Implementation\ProjectSystem\VisualStudioProjectTracker.cs" />
......
......@@ -6,7 +6,7 @@
using Microsoft.CodeAnalysis.Options;
using Microsoft.Internal.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.LanguageServices;
using Microsoft.VisualStudio.LanguageServices.Setup;
namespace Microsoft.VisualStudio.LanguageServices.Telemetry
......@@ -35,7 +35,7 @@ public void Initialize(IServiceProvider serviceProvider)
new VSTelemetryActivityLogger(telemetryService),
Logger.GetLogger()));
Logger.Log(FunctionId.Run_Environment, KeyValueLogMessage.Create(m => m["Version"] = FileVersionInfo.GetVersionInfo(typeof(Sqm).Assembly.Location).FileVersion));
Logger.Log(FunctionId.Run_Environment, KeyValueLogMessage.Create(m => m["Version"] = FileVersionInfo.GetVersionInfo(typeof(VisualStudioWorkspace).Assembly.Location).FileVersion));
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册