-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: Add flag to enable analyzers #336
Changes from all commits
6653003
a3adac1
a2204a1
70c5d43
55c4dd9
07b49ac
f73fe62
531b720
95ce1e0
4e6f864
2707cc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
is_global = true | ||
|
||
# IDE0055: Fix formatting | ||
dotnet_diagnostic.IDE0055.severity = warning | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,6 +406,13 @@ | |
"type": "parameter", | ||
"datatype": "bool" | ||
}, | ||
"analyzers": { | ||
"displayName": "Analyzers", | ||
"description": "Enable C# analyzers", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's give this a better description... what do I get with these analyzers? Technically even without this Analyzers are enabled in the project... it's a specific subset that we're enabling here... |
||
"type": "parameter", | ||
"datatype": "bool", | ||
"defaultValue": "true" | ||
}, | ||
"configuration": { | ||
"displayName": "Configuration", | ||
"description": "Load configuration information from appsettings.json", | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -52,6 +52,17 @@ | |||
<AndroidMaterialVersion Condition=" '$(AndroidMaterialVersion)' == '' ">1.9.0.2</AndroidMaterialVersion> | ||||
<AndroidXNavigationVersion Condition=" '$(AndroidXNavigationVersion)' == '' ">2.6.0.1</AndroidXNavigationVersion> | ||||
<!--#endif--> | ||||
<!--#if (analyzers)--> | ||||
|
||||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> | ||||
<EnableNETAnalyzers>true</EnableNETAnalyzers> | ||||
<AnalysisMode>Recommended</AnalysisMode> | ||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably should remove this, and instead pass it here:
|
||||
|
||||
<!-- CA1010: Type 'MainPage' directly or indirectly inherits 'IEnumerable' without implementing 'IEnumerable<T>' --> | ||||
<!-- CA1848: For improved performance, use the LoggerMessage delegates --> | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will need to look into this. |
||||
<NoWarn>$(NoWarn);CA1010;CA1848</NoWarn> | ||||
<!--#endif--> | ||||
</PropertyGroup> | ||||
|
||||
<Choose> | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
//-:cnd:noEmit | ||
using System.Globalization; | ||
|
||
namespace MyExtensionsApp._1; | ||
|
||
//+:cnd:noEmit | ||
|
@@ -123,7 +125,7 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args) | |
credentials ??= new Dictionary<string, string>(); | ||
credentials[TokenCacheExtensions.AccessTokenKey] = "SampleToken"; | ||
credentials[TokenCacheExtensions.RefreshTokenKey] = "RefreshToken"; | ||
credentials["Expiry"] = DateTime.Now.AddMinutes(5).ToString("g"); | ||
credentials["Expiry"] = DateTime.Now.AddMinutes(5).ToString("g", DateTimeFormatInfo.InvariantInfo); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: This is a behavioral change. When using a null provider, the used default will be CurrentInfo which doesn't seem suitable here. |
||
return ValueTask.FromResult<IDictionary<string, string>?>(credentials); | ||
} | ||
|
||
|
@@ -142,7 +144,7 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args) | |
// Return IDictionary containing any tokens used by service calls or in the app | ||
tokenDictionary ??= new Dictionary<string, string>(); | ||
tokenDictionary[TokenCacheExtensions.AccessTokenKey] = "NewSampleToken"; | ||
tokenDictionary["Expiry"] = DateTime.Now.AddMinutes(5).ToString("g"); | ||
tokenDictionary["Expiry"] = DateTime.Now.AddMinutes(5).ToString("g", DateTimeFormatInfo.InvariantInfo); | ||
return ValueTask.FromResult<IDictionary<string, string>?>(tokenDictionary); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -23,7 +23,7 @@ public WeatherCache(IApiClient api, ISerializer serializer) | |||||
} | ||||||
#endif | ||||||
|
||||||
private bool IsConnected => NetworkInformation.GetInternetConnectionProfile().GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess; | ||||||
private static bool IsConnected => NetworkInformation.GetInternetConnectionProfile().GetNetworkConnectivityLevel() == NetworkConnectivityLevel.InternetAccess; | ||||||
|
||||||
public async ValueTask<IImmutableList<WeatherForecast>> GetForecast(CancellationToken token) | ||||||
{ | ||||||
|
@@ -38,7 +38,7 @@ public async ValueTask<IImmutableList<WeatherForecast>> GetForecast(Cancellation | |||||
#if (useLogging) | ||||||
_logger.LogWarning("App is offline and cannot connect to the API."); | ||||||
#endif | ||||||
throw new Exception("No internet connection"); | ||||||
throw new InvalidOperationException("No internet connection"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking maybe change this to:
Suggested change
|
||||||
} | ||||||
|
||||||
var response = await _api.GetWeather(token); | ||||||
|
@@ -62,10 +62,10 @@ public async ValueTask<IImmutableList<WeatherForecast>> GetForecast(Cancellation | |||||
} | ||||||
} | ||||||
|
||||||
private async ValueTask<StorageFile> GetFile(CreationCollisionOption option) => | ||||||
private static async ValueTask<StorageFile> GetFile(CreationCollisionOption option) => | ||||||
await ApplicationData.Current.TemporaryFolder.CreateFileAsync("weather.json", option); | ||||||
|
||||||
private async ValueTask<string?> GetCachedWeather() | ||||||
private static async ValueTask<string?> GetCachedWeather() | ||||||
{ | ||||||
var file = await GetFile(CreationCollisionOption.OpenIfExists); | ||||||
var properties = await file.GetBasicPropertiesAsync(); | ||||||
|
@@ -84,6 +84,6 @@ private async ValueTask Save(IImmutableList<WeatherForecast> weather, Cancellati | |||||
{ | ||||||
var weatherText = _serializer.ToString(weather); | ||||||
var file = await GetFile(CreationCollisionOption.ReplaceExisting); | ||||||
await File.WriteAllTextAsync(file.Path, weatherText); | ||||||
await File.WriteAllTextAsync(file.Path, weatherText, token); | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not add this file. You should be able to set the diagnostic in the .editorconfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.globalconfig is now considered the "modern"/"encouraged" alternative of .editorconfig. I'd definitely use .globalconfigs for setting severities instead of .editorconfigs. It also has a "slight" performance improvement on Roslyn side since globalconfigs are evaluated per project rather than per file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we have something compelling from Microsoft for why we should move away from .editorconfig I'm hesitant to allow yet another file in. Not to mention what you are doing here is already supported in .editorconfig, and we already configure diagnostics in the .editorconfig. We don't need to make it harder on developers by giving them 2 files to maintain.