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 Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@
<SdkTargetFramework>$(NetCurrent)</SdkTargetFramework>
<VisualStudioServiceTargetFramework>net9.0</VisualStudioServiceTargetFramework>

<!-- NU1701 Disable implicit package target fallback, and disable warning for when we explicitly add it (currently needed for
Microsoft.ApplicationInsights) -->
<!-- NU1507 Disable multi-feed check as .NET uses multiple internal feeds intentionally -->
<!-- NU5039 Disable NuGet is unable to find the readme file in the package. -->
<NoWarn>$(NoWarn);NU1701;NU1507;NU1202;NU5039</NoWarn>
<NoWarn>$(NoWarn);NU1507;NU1202;NU5039</NoWarn>
<!-- do not enable analyzers on source build-->
<EnforceCodeStyleInBuild Condition="'$(DotNetBuildSourceOnly)' != 'true'">true</EnforceCodeStyleInBuild>
<UseSharedCompilation Condition="'$(DotNetBuildSourceOnly)' == 'true'">false</UseSharedCompilation>
Expand Down
8 changes: 6 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,23 @@
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="Basic.CompilerLog.Util" Version="0.9.18" />
<PackageVersion Include="AwesomeAssertions" Version="$(AwesomeAssertionsVersion)" />
<PackageVersion Include="AwesomeAssertions.Json" Version="$(AwesomeAssertionsJsonVersion)" />
<PackageVersion Include="Azure.Monitor.OpenTelemetry.Exporter" Version="$(AzureMonitorOpenTelemetryExporterPackageVersion)" />
<PackageVersion Include="Basic.CompilerLog.Util" Version="0.9.18" />
<PackageVersion Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="$(BenchmarkDotNetDiagnosticsWindowsPackageVersion)" />
<PackageVersion Include="MessagePack" Version="3.1.4" />
<PackageVersion Include="MicroBuild.Plugins.SwixBuild.Dotnet" Version="1.1.87-gba258badda" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="$(MicrosoftApplicationInsightsPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.DeveloperCertificates.XPlat" Version="$(MicrosoftAspNetCoreDeveloperCertificatesXPlatPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Tooling.Internal" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="$(MicrosoftAspNetCoreTestHostPackageVersion)" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="$(MicrosoftBclAsyncInterfacesPackageVersion)" />
<PackageVersion Include="Microsoft.Build.NuGetSdkResolver" Version="$(MicrosoftBuildNuGetSdkResolverPackageVersion)" />
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="$(OpenTelemetryVersion)" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="$(OpenTelemetryVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="$(OpenTelemetryVersion)" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="$(OpenTelemetryVersion)" />
<!-- roslyn dependencies -->
<PackageVersion Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
Expand Down
2 changes: 1 addition & 1 deletion documentation/general/tab-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Input | becomes
`dotnet a⇥` | `dotnet add` | `add` is the first subcommand, alphabetically.
`dotnet add p⇥` | `dotnet add --help` | it matches substrings and `--help` comes first alphabetically.
`dotnet add p⇥⇥` | `dotnet add package` | pressing tab a second time brings up the next suggestion.
`dotnet add package Microsoft⇥` | `dotnet add package Microsoft.ApplicationInsights.Web` | results are returned alphabetically.
`dotnet add package Microsoft⇥` | `dotnet add package Microsoft.AspNetCore.Http` | results are returned alphabetically.
`dotnet remove reference ⇥` | `dotnet remove reference ..\..\src\OmniSharp.DotNet\OmniSharp.DotNet.csproj` | it is project file aware.

## How to enable it
Expand Down
14 changes: 13 additions & 1 deletion eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,22 @@
<FileSignInfo Include="MessagePack.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.Api.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.Api.ProviderBuilderExtensions.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.Exporter.InMemory.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.Exporter.OpenTelemetryProtocol.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.Extensions.Hosting.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.Instrumentation.Http.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.Instrumentation.Runtime.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.PersistentStorage.Abstractions.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="OpenTelemetry.PersistentStorage.FileSystem.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Spectre.Console.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Valleysoft.DockerCredsProvider.dll" CertificateName="$(ExternalCertificateId)" />
</ItemGroup>

<!-- Additionally, we need to notarize any .pkg files -->
<!-- Additionally, we need to notarize any .pkg files -->
<ItemGroup>
<MacOSPkg Include="$(ArtifactsShippingPackagesDir)**/dotnet-sdk*.pkg" Exclude="$(ArtifactsShippingPackagesDir)**/dotnet-sdk-internal*.pkg" />
<FileSignInfo Include="@(MacOSPkg->'%(Filename)%(Extension)')" CertificateName="MacDeveloperWithNotarization" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
</PropertyGroup>
<PropertyGroup Label="Production dependencies">
<MicrosoftCssParserVersion>1.0.0-20230414.1</MicrosoftCssParserVersion>
<MicrosoftApplicationInsightsPackageVersion>2.23.0</MicrosoftApplicationInsightsPackageVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.1-servicing-26011-01</NETStandardLibraryNETFrameworkVersion>
<NETStandardLibraryVersion>2.0.3</NETStandardLibraryVersion>
<NewtonsoftJsonPackageVersion>13.0.3</NewtonsoftJsonPackageVersion>
Expand All @@ -60,6 +59,8 @@
<MicrosoftWindowsCsWin32PackageVersion>0.3.264</MicrosoftWindowsCsWin32PackageVersion>
<!-- When updating MicrosoftVisualStudioSolutionPersistenceVersion make sure to sync with dotnet/msbuild, dotnet/source-build-externals and NuGet/NuGet.Client -->
<MicrosoftVisualStudioSolutionPersistenceVersion>1.0.52</MicrosoftVisualStudioSolutionPersistenceVersion>
<AzureMonitorOpenTelemetryExporterPackageVersion>1.4.0</AzureMonitorOpenTelemetryExporterPackageVersion>
<OpenTelemetryVersion>1.12.0</OpenTelemetryVersion>
</PropertyGroup>

<PropertyGroup Label="MicroBuild.Core version">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ internal sealed class DotNetCommandDefinition : RootCommand
Arity = ArgumentArity.Zero
};

public readonly Option<bool> ListSdksOption = new("--list-sdks")
public readonly Option<bool> CliSchemaOption = new("--cli-schema")
{
Arity = ArgumentArity.Zero
Description = CommandDefinitionStrings.SDKSchemaCommandDefinition,
Arity = ArgumentArity.Zero,
Recursive = true,
Hidden = true,
};

public readonly Option<bool> ListRuntimesOption = new("--list-runtimes")
public readonly Option<bool> ListSdksOption = new("--list-sdks")
{
Arity = ArgumentArity.Zero
};

public readonly Option<bool> CliSchemaOption = new("--cli-schema")
public readonly Option<bool> ListRuntimesOption = new("--list-runtimes")
{
Description = CommandDefinitionStrings.SDKSchemaCommandDefinition,
Arity = ArgumentArity.Zero,
Recursive = true,
Hidden = true,
Arity = ArgumentArity.Zero
};

public readonly AddCommandDefinition AddCommand;
Expand Down Expand Up @@ -121,9 +121,11 @@ public DotNetCommandDefinition()
Options.Add(DiagOption);
Options.Add(VersionOption);
Options.Add(InfoOption);
Options.Add(CliSchemaOption);

// Host-handled options. Only defined to be shown in help.
Options.Add(ListSdksOption);
Options.Add(ListRuntimesOption);
Options.Add(CliSchemaOption);

Subcommands.Add(AddCommand = new());
Subcommands.Add(BuildCommand = new());
Expand Down
2 changes: 0 additions & 2 deletions src/Cli/Microsoft.DotNet.Cli.Utils/Activities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#if NET

using System.Diagnostics;

namespace Microsoft.DotNet.Cli.Utils;

/// <summary>
Expand Down
2 changes: 0 additions & 2 deletions src/Cli/Microsoft.DotNet.Cli.Utils/BuiltInCommand.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;

namespace Microsoft.DotNet.Cli.Utils;

/// <summary>
Expand Down
12 changes: 10 additions & 2 deletions src/Cli/Microsoft.DotNet.Cli.Utils/ITelemetryFilter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.CommandLine;

namespace Microsoft.DotNet.Cli.Utils;

public interface ITelemetryFilter
{
IEnumerable<ApplicationInsightsEntryFormat> Filter(object o);
IEnumerable<TelemetryEntryFormat> Filter(ParseResult parseResult);

IEnumerable<TelemetryEntryFormat> Filter(ParseResultWithGlobalJsonState parseData);

IEnumerable<TelemetryEntryFormat> Filter(InstallerSuccessReport report);

IEnumerable<TelemetryEntryFormat> Filter(Exception exception);
}
9 changes: 9 additions & 0 deletions src/Cli/Microsoft.DotNet.Cli.Utils/InstallerSuccessReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.DotNet.Cli.Utils;

public class InstallerSuccessReport(string? exeName)
{
public string ExeName { get; } = exeName ?? throw new ArgumentNullException(nameof(exeName));
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#if NET

using System.Diagnostics;
using Microsoft.DotNet.Cli.Utils.Extensions;

namespace Microsoft.DotNet.Cli.Utils;
Expand All @@ -16,7 +15,7 @@ internal sealed class MSBuildForwardingAppWithoutLogging

public static string MSBuildVersion
{
get => Microsoft.Build.Evaluation.ProjectCollection.DisplayVersion;
get => Build.Evaluation.ProjectCollection.DisplayVersion;
}
private const string MSBuildExeName = "MSBuild.dll";

Expand Down Expand Up @@ -194,7 +193,7 @@ private static string GetMSBuildExePath()
MSBuildExeName);
}

private static string GetMSBuildSDKsPath()
public static string GetMSBuildSDKsPath()
{
var envMSBuildSDKsPath = Environment.GetEnvironmentVariable("MSBuildSDKsPath");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Diagnostics.DiagnosticSource" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.Cli.CoreUtils\Microsoft.DotNet.Cli.CoreUtils.csproj" />
</ItemGroup>
Expand Down
105 changes: 36 additions & 69 deletions src/Cli/Microsoft.DotNet.Cli.Utils/TelemetryEventEntry.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.CommandLine;

namespace Microsoft.DotNet.Cli.Utils;

Expand All @@ -10,104 +10,71 @@ public static class TelemetryEventEntry
public static event EventHandler<InstrumentationEventArgs>? EntryPosted;
public static ITelemetryFilter TelemetryFilter { get; set; } = new BlockFilter();

public static void TrackEvent(
string? eventName = null,
IDictionary<string, string?>? properties = null,
IDictionary<string, double>? measurements = null)
public static void TrackEvent(string eventName, IDictionary<string, string?>? properties = null)
{
EntryPosted?.Invoke(typeof(TelemetryEventEntry),
new InstrumentationEventArgs(eventName, properties, measurements));
EntryPosted?.Invoke(typeof(TelemetryEventEntry), new InstrumentationEventArgs(eventName, properties));
}

public static void SendFiltered(object? o = null)
{
if (o == null)
{
return;
}
public static void SendFiltered(ParseResult parseResult) =>
SendFiltered(TelemetryFilter.Filter(parseResult));

public static void SendFiltered(ParseResultWithGlobalJsonState parseData) =>
SendFiltered(TelemetryFilter.Filter(parseData));

foreach (ApplicationInsightsEntryFormat entry in TelemetryFilter.Filter(o))
public static void SendFiltered(InstallerSuccessReport report) =>
SendFiltered(TelemetryFilter.Filter(report));

public static void SendFiltered(Exception exception) =>
SendFiltered(TelemetryFilter.Filter(exception));

private static void SendFiltered(IEnumerable<TelemetryEntryFormat> entries)
{
foreach (TelemetryEntryFormat entry in entries)
{
TrackEvent(entry.EventName, entry.Properties, entry.Measurements);
TrackEvent(entry.EventName, entry.Properties);
}
}

public static void Subscribe(Action<string?, IDictionary<string, string?>?, IDictionary<string, double>?> subscriber)
public static void Subscribe(Action<string, IDictionary<string, string?>?> subscriber)
{
void Handler(object? sender, InstrumentationEventArgs eventArgs)
{
subscriber(eventArgs.EventName, eventArgs.Properties, eventArgs.Measurements);
subscriber(eventArgs.EventName, eventArgs.Properties);
}

EntryPosted += Handler;
}
}

public sealed class PerformanceMeasurement : IDisposable
public class BlockFilter : ITelemetryFilter
{
private readonly Stopwatch? _timer;
private readonly Dictionary<string, double>? _data;
private readonly string? _name;
private static readonly TelemetryEntryFormat[] s_emptyEntries = [];

public PerformanceMeasurement(Dictionary<string, double>? data, string name)
{
// Measurement is a no-op if we don't have a dictionary to store the entry.
if (data == null)
{
return;
}
public IEnumerable<TelemetryEntryFormat> Filter(ParseResult parseResult) => s_emptyEntries;

_data = data;
_name = name;
_timer = Stopwatch.StartNew();
}
public IEnumerable<TelemetryEntryFormat> Filter(ParseResultWithGlobalJsonState parseData) => s_emptyEntries;

public void Dispose()
{
if (_name is not null && _timer is not null)
{
_data?.Add(_name, _timer.Elapsed.TotalMilliseconds);
}
}
}
public IEnumerable<TelemetryEntryFormat> Filter(InstallerSuccessReport report) => s_emptyEntries;

public class BlockFilter : ITelemetryFilter
{
public IEnumerable<ApplicationInsightsEntryFormat> Filter(object o)
{
return [];
}
public IEnumerable<TelemetryEntryFormat> Filter(Exception exception) => s_emptyEntries;
}

public class InstrumentationEventArgs : EventArgs
public class InstrumentationEventArgs(string eventName, IDictionary<string, string?>? properties = null) : EventArgs
{
internal InstrumentationEventArgs(
string? eventName,
IDictionary<string, string?>? properties,
IDictionary<string, double>? measurements)
{
EventName = eventName;
Properties = properties;
Measurements = measurements;
}

public string? EventName { get; }
public IDictionary<string, string?>? Properties { get; }
public IDictionary<string, double>? Measurements { get; }
public string EventName { get; } = eventName;
public IDictionary<string, string?>? Properties { get; } = properties;
}

public class ApplicationInsightsEntryFormat(
string? eventName = null,
IDictionary<string, string?>? properties = null,
IDictionary<string, double>? measurements = null)
public class TelemetryEntryFormat(string eventName, IDictionary<string, string?>? properties = null)
{
public string? EventName { get; } = eventName;
public string EventName { get; } = eventName;
public IDictionary<string, string?>? Properties { get; } = properties;
public IDictionary<string, double>? Measurements { get; } = measurements;

public ApplicationInsightsEntryFormat WithAppliedToPropertiesValue(Func<string?, string> func)
public TelemetryEntryFormat WithAppliedToPropertiesValue(Func<string, string> func)
{
var appliedProperties = Properties?.ToDictionary(p => p.Key, p => (string?)func(p.Value));
return new ApplicationInsightsEntryFormat(EventName, appliedProperties, Measurements);
var appliedProperties = Properties?.ToDictionary(p => p.Key, p => (string?)func(p.Value ?? string.Empty));
return new TelemetryEntryFormat(EventName, appliedProperties);
}
}

public record ParseResultWithGlobalJsonState(ParseResult ParseResult, string? GlobalJsonState);
6 changes: 3 additions & 3 deletions src/Cli/Microsoft.DotNet.Cli.Utils/UILanguageOverride.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
using System.Globalization;
using System.Security;
using Microsoft.Win32;
Expand All @@ -11,6 +10,7 @@ namespace Microsoft.DotNet.Cli.Utils;
internal static class UILanguageOverride
{
internal const string DOTNET_CLI_UI_LANGUAGE = nameof(DOTNET_CLI_UI_LANGUAGE);
private const string DOTNET_CLI_CONSOLE_USE_DEFAULT_ENCODING = nameof(DOTNET_CLI_CONSOLE_USE_DEFAULT_ENCODING);
private const string VSLANG = nameof(VSLANG);
private const string PreferredUILang = nameof(PreferredUILang);
// We choose UTF8 as the default encoding as opposed to specific language encodings because it supports emojis & other chars in .NET.
Expand All @@ -25,7 +25,7 @@ public static void Setup()
FlowOverrideToChildProcesses(language);
}

if (Env.GetEnvironmentVariable("DOTNET_CLI_CONSOLE_USE_DEFAULT_ENCODING") != "1")
if (Env.GetEnvironmentVariable(DOTNET_CLI_CONSOLE_USE_DEFAULT_ENCODING) != "1")
{
if (
!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("en", StringComparison.InvariantCultureIgnoreCase) &&
Expand Down
Loading
Loading