diff --git a/Directory.Build.props b/Directory.Build.props index 73428ad..f07a433 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -46,6 +46,8 @@ net10.0 $(LocalStackModernMinimumTargetFramework);net11.0 netstandard2.0 + + netstandard2.0 net472 $(LocalStackNetStandardTargetFramework);$(LocalStackNetFrameworkTargetFramework);$(LocalStackModernTargetFrameworks) diff --git a/Directory.Packages.props b/Directory.Packages.props index 3c8e08f..c5b974a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -186,7 +186,7 @@ runtime; build; native; contentfiles; analyzers - + diff --git a/build/LocalStack.Build/BuildContext.cs b/build/LocalStack.Build/BuildContext.cs index 5c77e89..156d19c 100644 --- a/build/LocalStack.Build/BuildContext.cs +++ b/build/LocalStack.Build/BuildContext.cs @@ -117,6 +117,9 @@ public BuildContext(ICakeContext context) : base(context) public ConvertableFilePath LocalStackClientExtProjFile { get; } + public string LocalStackNetFrameworkTargetFramework => + GetProjectProperties(LocalStackClientProjFile.ToString(), NetFrameworkTargetFrameworkProperty)[NetFrameworkTargetFrameworkProperty]; + /// /// Gets the effective package version for LocalStack.Client package. /// This value is cached to ensure consistency across pack and publish operations. @@ -174,7 +177,7 @@ public IEnumerable GetProjMetadata() { string csProjPath = csProj.FullPath; - Dictionary properties = GetProjectProperties(csProjPath, "TargetFrameworks", "TargetFramework", RunsAsPublishedExecutableProperty); + Dictionary properties = GetProjectProperties(csProjPath, TargetFrameworksProperty, TargetFrameworkProperty, RunsAsPublishedExecutableProperty); IEnumerable targetFrameworks = SplitTargetFrameworks(properties); string directoryPath = csProj.GetDirectory().FullPath; string assemblyName = GetAssemblyName(csProjPath); @@ -389,13 +392,16 @@ private static string ToPreReleaseIdentifier(string identifier) // Test projects that set this property are published and run as native executables by CI, not by 'dotnet test'. private const string RunsAsPublishedExecutableProperty = "LocalStackTestRunsAsPublishedExecutable"; + private const string TargetFrameworksProperty = "TargetFrameworks"; + private const string TargetFrameworkProperty = "TargetFramework"; + private const string NetFrameworkTargetFrameworkProperty = "LocalStackNetFrameworkTargetFramework"; private static string[] GetProjectTargetFrameworks(string csprojPath) => - SplitTargetFrameworks(GetProjectProperties(csprojPath, "TargetFrameworks", "TargetFramework")); + SplitTargetFrameworks(GetProjectProperties(csprojPath, TargetFrameworksProperty, TargetFrameworkProperty)); private static string[] SplitTargetFrameworks(Dictionary properties) { - string frameworks = string.IsNullOrWhiteSpace(properties["TargetFrameworks"]) ? properties["TargetFramework"] : properties["TargetFrameworks"]; + string frameworks = string.IsNullOrWhiteSpace(properties[TargetFrameworksProperty]) ? properties[TargetFrameworkProperty] : properties[TargetFrameworksProperty]; return frameworks.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); } diff --git a/build/LocalStack.Build/CakeTasks/TestTask.cs b/build/LocalStack.Build/CakeTasks/TestTask.cs index bb2a501..983b2e4 100644 --- a/build/LocalStack.Build/CakeTasks/TestTask.cs +++ b/build/LocalStack.Build/CakeTasks/TestTask.cs @@ -17,6 +17,7 @@ public override void Run(BuildContext context) }; IEnumerable projMetadata = context.GetProjMetadata(); + string netFrameworkTargetFramework = context.LocalStackNetFrameworkTargetFramework; foreach (ProjMetadata testProj in projMetadata) { @@ -56,7 +57,7 @@ public override void Run(BuildContext context) } // The .NET 11 SDK's test platform runs .NET Framework tests on Windows only; Mono is no longer supported. - if (targetFramework == "net472" && !context.IsRunningOnWindows()) + if (targetFramework == netFrameworkTargetFramework && !context.IsRunningOnWindows()) { ConsoleHelper.WriteWarning($"Skipping {targetFramework} tests for {testProj.AssemblyName}: .NET Framework tests run on Windows only"); diff --git a/src/LocalStack.Client.Generators/LocalStack.Client.Generators.csproj b/src/LocalStack.Client.Generators/LocalStack.Client.Generators.csproj index a93a653..26b7f71 100644 --- a/src/LocalStack.Client.Generators/LocalStack.Client.Generators.csproj +++ b/src/LocalStack.Client.Generators/LocalStack.Client.Generators.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + $(LocalStackAnalyzerTargetFramework) false true false diff --git a/src/LocalStack.Client/LocalStack.Client.csproj b/src/LocalStack.Client/LocalStack.Client.csproj index de13740..5a66bc2 100644 --- a/src/LocalStack.Client/LocalStack.Client.csproj +++ b/src/LocalStack.Client/LocalStack.Client.csproj @@ -34,7 +34,7 @@ - diff --git a/src/LocalStack.Client/Utils/S3ForcePathStyle.cs b/src/LocalStack.Client/Utils/S3ForcePathStyle.cs index 083d561..b769f66 100644 --- a/src/LocalStack.Client/Utils/S3ForcePathStyle.cs +++ b/src/LocalStack.Client/Utils/S3ForcePathStyle.cs @@ -10,7 +10,7 @@ internal static class S3ForcePathStyle internal static bool TrySet(ClientConfig clientConfig, bool value) { - if (string.Equals(clientConfig.ServiceId, "S3", StringComparison.Ordinal)) + if (string.Equals(clientConfig.ServiceId, AwsServiceEndpointMetadata.S3.ServiceId, StringComparison.Ordinal)) { SetForcePathStyle(clientConfig, value); return true; diff --git a/tests/LocalStack.Client.Functional.Tests/Scenarios/SNS/BaseSnsScenario.cs b/tests/LocalStack.Client.Functional.Tests/Scenarios/SNS/BaseSnsScenario.cs index 43d8f0e..9a2e39b 100644 --- a/tests/LocalStack.Client.Functional.Tests/Scenarios/SNS/BaseSnsScenario.cs +++ b/tests/LocalStack.Client.Functional.Tests/Scenarios/SNS/BaseSnsScenario.cs @@ -74,7 +74,7 @@ public async Task SnsService_Should_Send_Publish_A_Message_Async() [Theory, InlineData("eu-central-1"), InlineData("us-west-1"), InlineData("af-south-1"), InlineData("ap-southeast-1"), InlineData("ca-central-1"), InlineData("eu-west-2"), InlineData("sa-east-1")] - public virtual async Task Multi_Region_Tests_Async(string systemName) + public virtual async Task SnsService_Should_Create_A_Sns_Topic_In_The_Configured_Region_Async(string systemName) { var sessionReflection = ServiceProvider.GetRequiredService(); var amazonSimpleNotificationService = ServiceProvider.GetRequiredService(); diff --git a/tests/LocalStack.Client.Tests/SessionTests/SessionReflectionTests.cs b/tests/LocalStack.Client.Tests/SessionTests/SessionReflectionTests.cs index 5cbffb3..3a5c30c 100644 --- a/tests/LocalStack.Client.Tests/SessionTests/SessionReflectionTests.cs +++ b/tests/LocalStack.Client.Tests/SessionTests/SessionReflectionTests.cs @@ -41,11 +41,24 @@ public void CreateClientByInterface_Should_Keep_Injected_Config_Identity_And_Err var reflection = new Mock(MockBehavior.Strict); Type expectedType = typeof(MockAmazonServiceClient); reflection.Setup(helper => helper.ExtractServiceMetadata(expectedType)) - .Returns(() => { calls.Add("metadata"); return metadata.Object; }); + .Returns(() => + { + calls.Add("metadata"); + return metadata.Object; + }); reflection.Setup(helper => helper.CreateClientConfig(expectedType)) - .Returns(() => { calls.Add("config"); return config; }); + .Returns(() => + { + calls.Add("config"); + return config; + }); reflection.Setup(helper => helper.SetForcePathStyle(config, true)) - .Returns(() => { calls.Add("style"); config.ForcePathStyle = true; return true; }); + .Returns(() => + { + calls.Add("style"); + config.ForcePathStyle = true; + return true; + }); var session = new Session(new SessionOptions(regionName: "eu-west-2"), new Config(new ConfigOptions()), reflection.Object); using AmazonServiceClient client = byInterface ? session.CreateClientByInterface()