Skip to content

4320 enable warnings as errors and fix any issues #4351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
7 changes: 3 additions & 4 deletions eng/Directory.Build.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@

<PropertyGroup>
<NoWarn>$(NoWarn);NU1507</NoWarn>
<NoWarn>$(NoWarn);NU1701</NoWarn>
</PropertyGroup>

<!-- uncomment this in a new PR and fix all errors -->
<!-- https://github.com/Azure/azure-functions-core-tools/issues/4320 -->
<!-- <PropertyGroup>
<!--<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> -->
</PropertyGroup> -->
</Project>
4 changes: 3 additions & 1 deletion src/Cli/ArtifactAssembler/ArtifactAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private async Task CreateVisualStudioCoreToolsAsync()
FileUtilities.CopyDirectory(inProcArtifactDirPath, createDirectory ? Path.Combine(consolidatedArtifactDirPath, Constants.InProc8DirectoryName) : consolidatedArtifactDirPath);
Directory.Delete(inProcArtifactDirPath, true);

return (artifactDirName, consolidatedArtifactDirPath);
return await Task.FromResult((artifactDirName, consolidatedArtifactDirPath));
}

private async Task CreateCliCoreToolsAsync()
Expand Down Expand Up @@ -365,6 +365,7 @@ private async Task CreateCliCoreToolsAsync()

Console.WriteLine("Finished assembling CLI Core Tools artifacts");
Console.WriteLine();
await Task.CompletedTask;
}

private (string artifactDirectory, string version) GetArtifactDirectoryAndVersionNumber(string extractedRootDirectory, string artifactName)
Expand Down Expand Up @@ -420,6 +421,7 @@ private async Task ExtractZipFilesInDirectoryAsync(string zipSourceDir, string e
FileUtilities.ExtractToDirectory(zipFile, destinationDir);
File.Delete(zipFile);
}
await Task.CompletedTask;
}
}
}
2 changes: 1 addition & 1 deletion src/Cli/func/Actions/HostActions/StartHostAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal class StartHostAction : BaseAction

public string JsonOutputFile { get; set; }

public string? HostRuntime { get; set; }
public string HostRuntime { get; set; }

public StartHostAction(ISecretsManager secretsManager, IProcessManager processManager)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/func/Actions/HostActions/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void Configure(IApplicationBuilder app)
});
}

IApplicationLifetime applicationLifetime = app.ApplicationServices
IApplicationLifetime applicationLifetime = app.ApplicationServices
.GetRequiredService<IApplicationLifetime>();

app.UseWebJobsScriptHost(applicationLifetime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ namespace Azure.Functions.Cli.Actions.HostActions.WebHost.Security
{
public class CliAuthenticationHandler<TOptions> : AuthenticationHandler<TOptions> where TOptions : AuthenticationSchemeOptions, new()
{
public CliAuthenticationHandler(IOptionsMonitor<TOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock)
: base(options, logger, encoder, clock)
public CliAuthenticationHandler(IOptionsMonitor<TOptions> options, ILoggerFactory logger, UrlEncoder encoder, TimeProvider timeProvider)
: base(options, logger, encoder)
Copy link
Member

Choose a reason for hiding this comment

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

do we not want to update the base to also taken in a time provider?

{
options.CurrentValue.TimeProvider = timeProvider;
}

protected override Task<AuthenticateResult> HandleAuthenticateAsync()
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/func/ConsoleApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ internal IAction Parse()
return action;
}
}
catch (CliArgumentsException ex)
catch (CliArgumentsException)
{
// TODO: we can probably display help here as well.
// This happens for actions that expect an ordered untyped options.
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/func/Helpers/RetryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static async Task Retry(Func<Task> func, int retryCount, TimeSpan retryDe
{
if (retryCount <= 0)
{
throw e;
throw;
}
retryCount--;
if (displayError)
Expand All @@ -50,7 +50,7 @@ public static async Task<T> Retry<T>(Func<Task<T>> func, int retryCount, TimeSpa
{
if (retryCount <= 0)
{
throw e;
throw;
}
retryCount--;
if (displayError)
Expand Down
9 changes: 3 additions & 6 deletions src/Cli/func/Telemetry/ExternalTelemetryProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ internal static class ExternalTelemetryProperties
/// </summary>
internal static string GetInstallationType()
{
if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows)
{
return "";
}

const string Key = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion";
const string ValueName = @"InstallationType";

try
{
return (string)Registry.GetValue(Key, ValueName, defaultValue: "");
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
? Registry.GetValue(Key, ValueName, defaultValue: "") as string
: "";
}
// Catch everything: this is for telemetry only.
catch (Exception e)
Expand Down
9 changes: 6 additions & 3 deletions src/Cli/func/Telemetry/Telemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ private void InitializeTelemetry()
{
var persistenceChannel = new PersistenceChannel.PersistenceChannel(sendersCount: _senderCount);
persistenceChannel.SendingInterval = TimeSpan.FromMilliseconds(1);
TelemetryConfiguration.Active.TelemetryChannel = persistenceChannel;
var telemetryConfiguration = new TelemetryConfiguration
{
TelemetryChannel = persistenceChannel,
ConnectionString = $"InstrumentationKey={Constants.TelemetryInstrumentationKey}"
};

_client = new TelemetryClient();
_client.InstrumentationKey = Constants.TelemetryInstrumentationKey;
_client = new TelemetryClient(telemetryConfiguration);
_client.Context.Session.Id = CurrentSessionId;
_client.Context.Device.OperatingSystem = RuntimeEnvironment.OperatingSystem;

Expand Down
7 changes: 7 additions & 0 deletions src/CoreToolsHost/AppLoader/HostFxr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ public unsafe struct hostfxr_initialize_parameters
public nint size;
public char* host_path;
public char* dotnet_root;

public hostfxr_initialize_parameters()
{
size = sizeof(hostfxr_initialize_parameters);
host_path = null;
dotnet_root = null;
}
};

[LibraryImport("hostfxr", EntryPoint = "hostfxr_initialize_for_dotnet_command_line",
Expand Down
2 changes: 1 addition & 1 deletion src/CoreToolsHost/LocalSettingsJsonParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace CoreToolsHost
{
internal static class LocalSettingsJsonParser
{
internal static async Task<JsonDocument> GetLocalSettingsJsonAsJObjectAsync()
internal static async Task<JsonDocument?> GetLocalSettingsJsonAsJObjectAsync()
{
var fullPath = Path.Combine(Environment.CurrentDirectory, "local.settings.json");

Expand Down