Skip to content

Commit

Permalink
Merge pull request #158 from aws/anirdave-update-net7
Browse files Browse the repository at this point in the history
feat: Update rules and recommendations for .NET 7
  • Loading branch information
aniruddhadave authored Nov 21, 2022
2 parents aba341c + 6f734a9 commit 40d04e0
Show file tree
Hide file tree
Showing 64 changed files with 1,530 additions and 51 deletions.
10 changes: 6 additions & 4 deletions RecommendationTools/RecommendationBatchUpdater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ static void Main(string[] args)
///////////////////////////////////////////////////////////////////////////
// ADD/MODIFY CODE BELOW TO UPDATE RECOMMENDATIONS AND/OR RULES FILES //
// NOTE: We need to verify compatibility of packages added by rules with //
// the target framework being added. //
// the target framework being added. //
///////////////////////////////////////////////////////////////////////////

const string PreviousDotnetVersion = "net6.0";
const string NextDotnetVersion = "net7.0";

var recommendations = Loader.LoadBatchRecommendations(o.Directory);
Updater.BatchAddFramework(recommendations, "net6.0");
Updater.BatchAddFramework(recommendations, NextDotnetVersion, PreviousDotnetVersion);
//Saver.SaveBatch(recommendations);

var rules = Loader.LoadBatchRules(o.Directory);
Updater.BatchAddFramework(rules, "net6.0");
Updater.BatchAddFramework(rules, NextDotnetVersion, PreviousDotnetVersion);
//Saver.SaveBatch(rules);
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

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

<ItemGroup>
<PackageReference Include="CTA.Rules.Models" Version="2.0.3" />
<PackageReference Include="CTA.Rules.Models" Version="2.6.5" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions RecommendationTools/RecommendationBatchUpdater/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace RecommendationBatchUpdater
{
public class Updater
{
public static void BatchAddFramework(Dictionary<string, RecommendationPOCO> recommendations, string frameworkToAdd)
public static void BatchAddFramework(Dictionary<string, RecommendationPOCO> recommendations, string frameworkToAdd, string mostRecentFrameworkAdded)
{
foreach (var (filePath, recommendationRoot) in recommendations)
{
Expand All @@ -19,7 +19,7 @@ public static void BatchAddFramework(Dictionary<string, RecommendationPOCO> reco
foreach (var recommendedAction in recommendation.RecommendedActions)
{
if (!recommendedAction.TargetFrameworks.Contains(frameworkToAdd)
&& recommendedAction.TargetFrameworks.Contains("net5.0"))
&& recommendedAction.TargetFrameworks.Contains(mostRecentFrameworkAdded))
{
recommendedAction.TargetFrameworks = recommendedAction.TargetFrameworks.Append(frameworkToAdd).ToArray();
}
Expand All @@ -33,7 +33,7 @@ public static void BatchAddFramework(Dictionary<string, RecommendationPOCO> reco
}
}

public static void BatchAddFramework(Dictionary<string, RulePOCO> recommendations, string frameworkToAdd)
public static void BatchAddFramework(Dictionary<string, RulePOCO> recommendations, string frameworkToAdd, string mostRecentFrameworkAdded)
{
foreach (var (filePath, recommendationRoot) in recommendations)
{
Expand All @@ -43,10 +43,10 @@ public static void BatchAddFramework(Dictionary<string, RulePOCO> recommendation
{
foreach (var recommendedAction in recommendation.RecommendedActions)
{
// Assuming frameworkToAdd > net5.0,
// only add it if net5.0 is already in TargetFrameworks
// Assuming frameworkToAdd > net6.0,
// only add it if net6.0 is already in TargetFrameworks
if (recommendedAction.TargetFrameworks.All(f => f.Name != frameworkToAdd)
&& recommendedAction.TargetFrameworks.Any(f => f.Name == "net5.0"))
&& recommendedAction.TargetFrameworks.Any(f => f.Name == mostRecentFrameworkAdded))
{
recommendedAction.TargetFrameworks.Add(new TargetFramework
{
Expand Down
9 changes: 9 additions & 0 deletions recommendation/antlr.runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Add a reference to Antlr3.Runtime",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/antlr.runtime.misc.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Add reference to Antlr3.Runtime",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/antlr.runtime.tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Add a reference to Antlr3.Runtime",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.channels.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.ServiceModel.Channels with CoreWCF.Channels Namespace. Check CoreWCF Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.codebased.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.ServiceModel.Configuration with CoreWCF.Configuration Namespace. Check CoreWCF.Configuration Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.configurationbased.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.description.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.ServiceModel.Description with CoreWCF.Description Namespace. Check CoreWCF.Description Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.diagnostics.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.ServiceModel.Diagnostics with CoreWCF.Diagnostics Namespace. Check CoreWCF.Diagnostics Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.dispatcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.ServiceModel.Dispatcher with CoreWCF.Dispatcher Namespace. Check CoreWCF.Dispatcher Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.identitymodel.claims.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.IdentityModel.Claims with CoreWCF.IdentityModel.Claims Namespace. Check CoreWCF.IdentityModel.Claims Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.identitymodel.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.IdentityModel with CoreWCF.IdentityModel Namespace. Check CoreWCF.IdentityModel Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.identitymodel.policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.IdentityModel.Policy with CoreWCF.IdentityModel.Policy Namespace. Check CoreWCF.IdentityModel.Policy Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.identitymodel.selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.IdentityModel.Selectors with CoreWCF.IdentityModel.Selectors Namespace. Check CoreWCF.IdentityModel.Selectors Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.identitymodel.services.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.IdentityModel.Services.Tokens with CoreWCF.IdentityModel.Services.Tokens Namespace. Check CoreWCF.IdentityModel.Services.Tokens Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.identitymodel.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.IdentityModel.Tokens with CoreWCF.IdentityModel.Tokens Namespace. Check CoreWCF.IdentityModel.Tokens Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.ServiceModel with CoreWCF Namespace. Check CoreWCF Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.security.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.ServiceModel.Security with CoreWCF.Security Namespace. Check CoreWCF.Security Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.security.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "Replace System.ServiceModel.Security.Tokens with CoreWCF.Security.Tokens Namespace. Check CoreWCF.Security.Tokens Compatibility at https://github.com/CoreWCF/CoreWCF/releases",
Expand Down
9 changes: 9 additions & 0 deletions recommendation/corewcf.servicelibrary.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
"ARM32",
"ARM64"
]
},
{
"Name": "net7.0",
"TargetCPU": [
"x86",
"x64",
"ARM32",
"ARM64"
]
}
],
"Description": "",
Expand Down
Loading

0 comments on commit 40d04e0

Please sign in to comment.