diff --git a/global.json b/global.json
index b8812fd69be..3339178a828 100644
--- a/global.json
+++ b/global.json
@@ -4,7 +4,7 @@
},
"sdk": {
"allowPrerelease": false,
- "version": "6.0.100",
+ "version": "6.0.400",
"rollForward": "latestFeature"
}
}
diff --git a/src/Bicep.Core.UnitTests/Diagnostics/LinterAnalyzerTests.cs b/src/Bicep.Core.UnitTests/Diagnostics/LinterAnalyzerTests.cs
index 10539e4ba3e..bc87126be67 100644
--- a/src/Bicep.Core.UnitTests/Diagnostics/LinterAnalyzerTests.cs
+++ b/src/Bicep.Core.UnitTests/Diagnostics/LinterAnalyzerTests.cs
@@ -62,7 +62,7 @@ public void AllDefinedRulesAreListInLinterRulesProvider()
var actualTypeNames = ruleTypes.Select(t => t.FullName ?? throw new ArgumentNullException("bad type"));
var expectedTypeNames = expectedRuleTypes.Select(t => t.FullName ?? throw new ArgumentNullException("bad type"));
- actualTypeNames.Should().BeEquivalentTo(expectedTypeNames, "LinterRuleProvider.GetRuleTypes() needs to be updated to list all defined rules in the core assembly");
+ actualTypeNames.Should().BeEquivalentTo(expectedTypeNames, "Please verify that the {nameof(LinterRuleTypeGenerator)} source generator is working correctly");
}
[TestMethod]
diff --git a/src/Bicep.Core/Analyzers/Interfaces/IBicepAnalyzerRule.cs b/src/Bicep.Core/Analyzers/Interfaces/IBicepAnalyzerRule.cs
index 9afdaf991a0..fbac8cd5aa4 100644
--- a/src/Bicep.Core/Analyzers/Interfaces/IBicepAnalyzerRule.cs
+++ b/src/Bicep.Core/Analyzers/Interfaces/IBicepAnalyzerRule.cs
@@ -15,6 +15,8 @@ namespace Bicep.Core.Analyzers.Interfaces
/// constructor which can be discoverd through
/// reflection
///
+ /// Do not rename or move this type to a different namespace.
+ /// We are using a source generator that requires the fully qualified type name of this interface to not change.
public interface IBicepAnalyzerRule
{
string AnalyzerName { get; }
diff --git a/src/Bicep.Core/Analyzers/Linter/LinterRulesProvider.cs b/src/Bicep.Core/Analyzers/Linter/LinterRulesProvider.cs
index c857f2d951c..463246acead 100644
--- a/src/Bicep.Core/Analyzers/Linter/LinterRulesProvider.cs
+++ b/src/Bicep.Core/Analyzers/Linter/LinterRulesProvider.cs
@@ -9,10 +9,11 @@
using System.Reflection;
using Bicep.Core.Analyzers.Interfaces;
using Bicep.Core.Analyzers.Linter.Rules;
+using Bicep.RoslynAnalyzers;
namespace Bicep.Core.Analyzers.Linter
{
- public class LinterRulesProvider : ILinterRulesProvider
+ public partial class LinterRulesProvider : ILinterRulesProvider
{
private readonly Lazy> linterRulesLazy;
@@ -39,39 +40,8 @@ public LinterRulesProvider()
return rules;
}
- public IEnumerable GetRuleTypes()
- {
- // Can't use reflection to get this list because the output dotnet executable is trimmed,
- // and dependencies that can't be determined at compile time get removed.
- return new[] {
- typeof(AdminUsernameShouldNotBeLiteralRule),
- typeof(ArtifactsParametersRule),
- typeof(ExplicitValuesForLocationParamsRule),
- typeof(MaxNumberOutputsRule),
- typeof(MaxNumberParametersRule),
- typeof(MaxNumberResourcesRule),
- typeof(MaxNumberVariablesRule),
- typeof(NoHardcodedEnvironmentUrlsRule),
- typeof(NoHardcodedLocationRule),
- typeof(NoLocationExprOutsideParamsRule),
- typeof(NoUnnecessaryDependsOnRule),
- typeof(NoUnusedExistingResourcesRule),
- typeof(NoUnusedParametersRule),
- typeof(NoUnusedVariablesRule),
- typeof(OutputsShouldNotContainSecretsRule),
- typeof(PreferInterpolationRule),
- typeof(PreferUnquotedPropertyNamesRule),
- typeof(SecretsInParamsMustBeSecureRule),
- typeof(SecureParameterDefaultRule),
- typeof(SecureParamsInNestedDeploymentsRule),
- typeof(SimplifyInterpolationRule),
- typeof(ProtectCommandToExecuteSecretsRule),
- typeof(UseRecentApiVersionRule),
- typeof(UseResourceIdFunctionsRule),
- typeof(UseStableResourceIdentifiersRule),
- typeof(UseStableVMImageRule),
- };
- }
+ [LinterRuleTypesGenerator]
+ public partial IEnumerable GetRuleTypes();
public ImmutableDictionary GetLinterRules() => linterRulesLazy.Value;
}
diff --git a/src/Bicep.Core/Bicep.Core.csproj b/src/Bicep.Core/Bicep.Core.csproj
index f7d2f2db8cf..8f77388fcd3 100644
--- a/src/Bicep.Core/Bicep.Core.csproj
+++ b/src/Bicep.Core/Bicep.Core.csproj
@@ -36,6 +36,7 @@
+
diff --git a/src/Bicep.Core/packages.lock.json b/src/Bicep.Core/packages.lock.json
index 42a7e346bbb..bda15731026 100644
--- a/src/Bicep.Core/packages.lock.json
+++ b/src/Bicep.Core/packages.lock.json
@@ -2,6 +2,12 @@
"version": 1,
"dependencies": {
"net6.0": {
+ "Azure.Bicep.Internal.RoslynAnalyzers": {
+ "type": "Direct",
+ "requested": "[0.1.17, )",
+ "resolved": "0.1.17",
+ "contentHash": "ItQGvv0R1znYHxbYx6VQTQdqqhLG+OsE5XtI6gGmPDiKXcSUpJD4UJNB3kOWAxbZDnB1HwEAJFegbjvv6YlcbA=="
+ },
"Azure.Bicep.Types": {
"type": "Direct",
"requested": "[0.2.115, )",