Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
<LocalStackModernMinimumTargetFramework>net10.0</LocalStackModernMinimumTargetFramework>
<LocalStackModernTargetFrameworks>$(LocalStackModernMinimumTargetFramework);net11.0</LocalStackModernTargetFrameworks>
<LocalStackNetStandardTargetFramework>netstandard2.0</LocalStackNetStandardTargetFramework>
<!-- Roslyn loads source generators only from netstandard2.0. -->
<LocalStackAnalyzerTargetFramework>netstandard2.0</LocalStackAnalyzerTargetFramework>
<LocalStackNetFrameworkTargetFramework>net472</LocalStackNetFrameworkTargetFramework>

<LocalStackClientTargetFrameworks>$(LocalStackNetStandardTargetFramework);$(LocalStackNetFrameworkTargetFramework);$(LocalStackModernTargetFrameworks)</LocalStackClientTargetFrameworks>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageVersion>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<ItemGroup Condition="'$(TargetFramework)' == '$(LocalStackNetFrameworkTargetFramework)'">
<PackageVersion Include="Microsoft.TestPlatform.ObjectModel" Version="18.11.0" />
</ItemGroup>
</Project>
12 changes: 9 additions & 3 deletions build/LocalStack.Build/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public BuildContext(ICakeContext context) : base(context)

public ConvertableFilePath LocalStackClientExtProjFile { get; }

public string LocalStackNetFrameworkTargetFramework =>
GetProjectProperties(LocalStackClientProjFile.ToString(), NetFrameworkTargetFrameworkProperty)[NetFrameworkTargetFrameworkProperty];

/// <summary>
/// Gets the effective package version for LocalStack.Client package.
/// This value is cached to ensure consistency across pack and publish operations.
Expand Down Expand Up @@ -174,7 +177,7 @@ public IEnumerable<ProjMetadata> GetProjMetadata()
{
string csProjPath = csProj.FullPath;

Dictionary<string, string> properties = GetProjectProperties(csProjPath, "TargetFrameworks", "TargetFramework", RunsAsPublishedExecutableProperty);
Dictionary<string, string> properties = GetProjectProperties(csProjPath, TargetFrameworksProperty, TargetFrameworkProperty, RunsAsPublishedExecutableProperty);
IEnumerable<string> targetFrameworks = SplitTargetFrameworks(properties);
string directoryPath = csProj.GetDirectory().FullPath;
string assemblyName = GetAssemblyName(csProjPath);
Expand Down Expand Up @@ -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<string, string> 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);
}
Expand Down
3 changes: 2 additions & 1 deletion build/LocalStack.Build/CakeTasks/TestTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public override void Run(BuildContext context)
};

IEnumerable<ProjMetadata> projMetadata = context.GetProjMetadata();
string netFrameworkTargetFramework = context.LocalStackNetFrameworkTargetFramework;

foreach (ProjMetadata testProj in projMetadata)
{
Expand Down Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>$(LocalStackAnalyzerTargetFramework)</TargetFramework>
<IsPackable>false</IsPackable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IncludeBuildOutput>false</IncludeBuildOutput>
Expand Down
2 changes: 1 addition & 1 deletion src/LocalStack.Client/LocalStack.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="AWSSDK.Core" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
<ProjectReference Include="../LocalStack.Client.Generators/LocalStack.Client.Generators.csproj" ReferenceOutputAssembly="false" PrivateAssets="all" />
<None Include="../LocalStack.Client.Generators/bin/$(Configuration)/netstandard2.0/LocalStack.Client.Generators.dll"
<None Include="../LocalStack.Client.Generators/bin/$(Configuration)/$(LocalStackAnalyzerTargetFramework)/LocalStack.Client.Generators.dll"
Pack="true" PackagePath="tools/LocalStack.Client.Generators" Visible="false" />
<None Include="buildTransitive/LocalStack.Client.targets" Pack="true" PackagePath="buildTransitive" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/LocalStack.Client/Utils/S3ForcePathStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ISessionReflection>();
var amazonSimpleNotificationService = ServiceProvider.GetRequiredService<IAmazonSimpleNotificationService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,24 @@ public void CreateClientByInterface_Should_Keep_Injected_Config_Identity_And_Err
var reflection = new Mock<Contracts.ISessionReflection>(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<IMockAmazonService>()
Expand Down
Loading