Skip to content

Commit

Permalink
Update to .NET 6.0 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
idg10 authored Dec 14, 2022
1 parent 8397eef commit 3b55027
Show file tree
Hide file tree
Showing 25 changed files with 92 additions and 1,975 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,6 @@ ASALocalRun/
coverage.cobertura.xml

# VS Code config files
/.vscode
/.vscode

*.feature.cs
2 changes: 1 addition & 1 deletion Solutions/Endjin.Badger/BadgePainter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static string DrawSVG(string subject, string status, string statusColor,
// This takes the fonts size in points, which are bigger than pixels. 1 points is 1/72 inches,
// whereas in web coordinate systems, 1 pixel is 1/96 inches. So we need to multiple by 0.75
// to provide the font size in pixels.
Font font = new Font(SystemFonts.Find("Verdana"), 11 * 0.75f, FontStyle.Regular);
Font font = new(SystemFonts.Find("Verdana"), 11 * 0.75f, FontStyle.Regular);

var subjectWidth = TextMeasurer.Measure(WebUtility.HtmlDecode(subject), new RendererOptions(font, 96)).Width + 8; //34.25086
var statusWidth = TextMeasurer.Measure(WebUtility.HtmlDecode(status), new RendererOptions(font, 96)).Width + 8; // 42.3075
Expand Down
22 changes: 11 additions & 11 deletions Solutions/Endjin.Badger/ColorScheme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
{
public static class ColorScheme
{
public static string BrightGreen = "#4c1";
public static string Green = "#97CA00";
public static string Yellow = "#dfb317";
public static string YellowGreen = "#a4a61d";
public static string Orange = "#fe7d37";
public static string Red = "#e05d44";
public static string Blue = "#007ec6";
public static string Grey = "#555";
public static string Gray = "#555";
public static string LightGrey = "#9f9f9f";
public static string LightGray = "#9f9f9f";
public const string BrightGreen = "#4c1";
public const string Green = "#97CA00";
public const string Yellow = "#dfb317";
public const string YellowGreen = "#a4a61d";
public const string Orange = "#fe7d37";
public const string Red = "#e05d44";
public const string Blue = "#007ec6";
public const string Grey = "#555";
public const string Gray = "#555";
public const string LightGrey = "#9f9f9f";
public const string LightGray = "#9f9f9f";
}
}
3 changes: 2 additions & 1 deletion Solutions/Endjin.Badger/Endjin.Badger.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>

<Nullable>enable</Nullable>
Expand All @@ -10,6 +10,7 @@
CA1303 is the insistence that exception arguments be localized which isn't useful for us.
-->
<NoWarn>CA1062;CA1303</NoWarn>
<NeutralLanguage>en-GB</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions Solutions/Endjin.Imm.App/Endjin.Imm.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<Nullable>enable</Nullable>

<NeutralLanguage>en-GB</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="YamlDotNet.NetCore" Version="1.0.0" />
</ItemGroup>

Expand Down
2 changes: 0 additions & 2 deletions Solutions/Endjin.Imm.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ private static async Task Main()
{
Console.WriteLine($"{result.RuleAssertion.Name} {result.Percentage}% Score: {result.Score}");

#pragma warning disable RCS1197 // Optimize StringBuilder.Append/AppendLine call.
col1.AppendLine($"<tspan x='30' dy='1.5em'>{WebUtility.HtmlEncode(result.RuleAssertion.Name)}</tspan>");
col2.AppendLine($"<tspan x='310' dy='1.5em'>{result.Percentage}%</tspan>");
#pragma warning restore RCS1197 // Optimize StringBuilder.Append/AppendLine call.

File.WriteAllText($"imm-{result.RuleAssertion.Id}.svg", BadgePainter.DrawSVG(WebUtility.HtmlEncode(result.RuleAssertion.Name!), $"{result.Percentage}%", ColorScheme.Red, Style.FlatSquare));
}
Expand Down
12 changes: 6 additions & 6 deletions Solutions/Endjin.Imm.Domain/Endjin.Imm.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>

<Nullable>enable</Nullable>
Expand All @@ -15,14 +15,14 @@
<NoWarn>CA1062;CA1303;CA1812</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="2.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NodaTime" Version="2.4.7" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="NodaTime" Version="3.1.6" />
<PackageReference Include="YamlDotNet.NetCore" Version="1.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
internal class HttpDeserializingCache<T>
where T : class
{
private readonly object sync = new object();
private readonly object sync = new();
private readonly IMemoryCache memoryCache;
private readonly HttpClient httpClient;
private readonly IHttpDeserializer<T> deserializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public partial class IpMaturityMatrixRuleset
(nameof(FrameworkMeasureDefinition.Framework), typeof(FrameworkMeasureDefinition)),
(nameof(AgeMeasureDefinition.Age), typeof(AgeMeasureDefinition)));

[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1055:Uri return values should not be strings", Justification = "We don't have any particular use for representing URIs as anything other than a string in this project")]
public static string DefinitionsUrlForName(string name) => $"https://raw.githubusercontent.com/endjin/Endjin.Ip.Maturity.Matrix.RuleDefinitions/{name}/RuleSet.yaml";

public static IpMaturityMatrixRuleset FromJson(string json) => JsonConvert.DeserializeObject<IpMaturityMatrixRuleset>(json, Converter.Settings) ?? new IpMaturityMatrixRuleset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public partial class RuleAssertion
public bool OptOut { get; set; }

[JsonProperty("measures")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "YamlDotNet.Serialization doesn't know how to deserialize a collection into a pre-initialized read-only property")]
public IList<MeasureAssertion> Measures { get; set; } = new List<MeasureAssertion>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public partial class RuleDefinition
public bool CanOptOut { get; set; }

[JsonProperty("measures")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "YamlDotNet.Serialization doesn't know how to deserialize a collection into a pre-initialized read-only property")]
public IList<MeasureDefinition> Measures { get; set; } = new List<MeasureDefinition>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected override long ScoreFromApplicableMeasures(CalculationContext context)

foreach (MeasureDefinition measureDefinition in context.ApplicableMeasureDefinitions)
{
if (!(measureDefinition is AgeMeasureDefinition amd))
if (measureDefinition is not AgeMeasureDefinition amd)
{
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
// The "ruleAssertion" argument name here is defined in IRuleCalculator.Score
Expand All @@ -106,7 +106,7 @@ protected override long ScoreFromApplicableMeasures(CalculationContext context)

// No Score or Date, so see if the rule definition includes an entry saying what to do if
// the Age is unknown.
if (context.ApplicableMeasureDefinitions.SingleOrDefault(m => !(m is AgeMeasureDefinition)) is MeasureDefinition measureDefForWhenAgeNotPresent)
if (context.ApplicableMeasureDefinitions.SingleOrDefault(m => m is not AgeMeasureDefinition) is MeasureDefinition measureDefForWhenAgeNotPresent)
{
return measureDefForWhenAgeNotPresent.Score;
}
Expand All @@ -127,7 +127,7 @@ private static bool LocalDateMatchesRule(LocalDate dateInImm, LocalDate referenc

static bool DateWithinPeriod(LocalDate dateInImm, LocalDate referenceDate, string ageText)
{
Period p = PeriodPattern.NormalizingIso.Parse(ageText.Substring(1)).Value;
Period p = PeriodPattern.NormalizingIso.Parse(ageText[1..]).Value;

LocalDate dateOnWhichNoLongerWithinPeriod = dateInImm.Plus(p);
return dateOnWhichNoLongerWithinPeriod > referenceDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected override long ScoreFromApplicableMeasures(CalculationContext context)
// There was a Framework, so we can do this properly.
foreach (MeasureDefinition measureDefinition in context.ApplicableMeasureDefinitions)
{
if (!(measureDefinition is FrameworkMeasureDefinition fmd))
if (measureDefinition is not FrameworkMeasureDefinition fmd)
{
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
// The "ruleAssertion" argument name here is defined in IRuleCalculator.Score
Expand All @@ -101,7 +101,7 @@ protected override long ScoreFromApplicableMeasures(CalculationContext context)

// No Score or Framework, so see if the rule definition includes an entry saying what to do if
// the Framework is unknown.
if (context.ApplicableMeasureDefinitions.SingleOrDefault(m => !(m is FrameworkMeasureDefinition)) is MeasureDefinition measureDefForWhenFrameworkNotPresent)
if (context.ApplicableMeasureDefinitions.SingleOrDefault(m => m is not FrameworkMeasureDefinition) is MeasureDefinition measureDefForWhenFrameworkNotPresent)
{
return measureDefForWhenFrameworkNotPresent.Score;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
public static readonly JsonSerializerSettings Settings = new()
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Expand Down
14 changes: 7 additions & 7 deletions Solutions/Endjin.Imm.Specs/Endjin.Imm.Specs.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>

Expand All @@ -15,18 +15,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Corvus.SpecFlow.Extensions" Version="0.7.0-preview.3" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.0">
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="SpecFlow.NUnit" Version="3.1.76" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.76" />
<PackageReference Include="coverlet.msbuild" Version="2.8.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" />
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 3b55027

Please sign in to comment.