Skip to content
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

Add logging when environment variable parsing fails #1251

Merged
merged 10 commits into from
Jun 15, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace SonarScanner.MSBuild.Common
Expand All @@ -48,7 +46,7 @@ public static bool TryCreateProvider(ILogger logger, out IAnalysisPropertyProvid
provider = new EnvScannerPropertiesProvider(Environment.GetEnvironmentVariable(ENV_VAR_KEY));
return true;
}
catch (Exception ex) when (ex is JsonException || ex is IOException)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

JsonException is in Newtonsoft 12 :|

hence failures on .NET Core 2.1

🤦

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to leave a comment here, so it will be fixed once NET 2.1 version is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do a separate PR to avoid postponing merging this one.

I think there's multiple things:

  • filtering down the exception
  • general cleanup after removing .NET 2.1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

catch (Exception ex)
{
logger.LogError(Resources.ERROR_FailedParsePropertiesEnvVar, ENV_VAR_KEY, ex.Message);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will fail the build, which is ok in this case (otherwise, users will be confused)

}
Expand Down
2 changes: 1 addition & 1 deletion src/SonarScanner.MSBuild.TFS/SummaryReportBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SummaryReportData
public int SkippedProjects { get; set; }
public int ExcludedProjects { get; set; }
public bool Succeeded { get; set; }
public string DashboardUrl { get; set; } // should be Uri https://github.com/SonarSource/sonar-scanner-msbuild/issues/1252
public string DashboardUrl { get; set; }
public string ProjectDescription { get; set; }
}

Expand Down