Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade dotnet sdk version. #239

Merged
merged 5 commits into from
Apr 16, 2024
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
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\Apollo.snk</AssemblyOriginatorKeyFile>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>10.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS0414;CS0436;CS1591</NoWarn>
Expand All @@ -16,6 +16,7 @@
<Using Include="System.Diagnostics" />
<Using Include="System.Diagnostics.CodeAnalysis" />
<Using Include="System.Net" />
<Using Include="System.Net.Http" />
<Using Include="System.Text" />
</ItemGroup>

Expand Down
6 changes: 4 additions & 2 deletions demo/Apollo.AspNetCore.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
if (string.IsNullOrWhiteSpace(key)) return Task.CompletedTask;

var value = context.RequestServices.GetRequiredService<IConfiguration>()[key];
if (value != null) context.Response.StatusCode = 200;
if (value == null) return Task.CompletedTask;

context.Response.StatusCode = 200;

context.Response.Headers["Content-Type"] = "text/html; charset=utf-8";

return context.Response.WriteAsync(value ?? "undefined");
return context.Response.WriteAsync(value);
});

app.Run();
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "8.0.100",
"rollForward": "latestMajor",
"allowPrerelease": false
}
Expand Down
12 changes: 6 additions & 6 deletions test/Apollo.OpenApi.Tests/AppClusterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public AppClusterTest(ITestOutputHelper output) : base(output) { }
[Fact]
public async Task GetEnvClusterInfo()
{
var result = await CreateAppClusterClient().GetEnvClusterInfo().ConfigureAwait(false);
var result = await CreateAppClusterClient().GetEnvClusterInfo();

Dump(result);

Expand All @@ -31,7 +31,7 @@ public async Task GetEnvClusterInfo()
[Fact]
public async Task GetCluster()
{
var result = await CreateAppClusterClient().GetCluster("DEV").ConfigureAwait(false);
var result = await CreateAppClusterClient().GetCluster("DEV");

Dump(result);

Expand All @@ -43,7 +43,7 @@ public async Task GetCluster()
[Fact]
public async Task GetAppInfo()
{
var result = await CreateAppClusterClient().GetAppInfo().ConfigureAwait(false);
var result = await CreateAppClusterClient().GetAppInfo();

Dump(result);

Expand All @@ -55,10 +55,10 @@ public async Task GetAppInfo()
[Fact]
public async Task GetAppsInfo()
{
var result = await CreateAppClusterClient().GetAppsInfo().ConfigureAwait(false);
var result = await CreateAppClusterClient().GetAppsInfo();

Assert.NotNull(result);
Assert.NotEmpty(result); result = await CreateAppClusterClient().GetAppsInfo(AppIds).ConfigureAwait(false);
Assert.NotEmpty(result); result = await CreateAppClusterClient().GetAppsInfo(AppIds);

Dump(result);

Expand All @@ -69,7 +69,7 @@ public async Task GetAppsInfo()
[Fact]
public async Task GetNamespaces()
{
var result = await CreateAppClusterClient().GetNamespaces(Env).ConfigureAwait(false);
var result = await CreateAppClusterClient().GetNamespaces(Env);

Dump(result);

Expand Down
30 changes: 15 additions & 15 deletions test/Apollo.OpenApi.Tests/NamespaceClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public async Task GetInfo()
{
var client = CreateNamespaceClient();

var result = await client.GetNamespaceInfo().ConfigureAwait(false);
var result = await client.GetNamespaceInfo();

Assert.NotNull(result);
Assert.Equal(client.AppId, result!.AppId);
Expand All @@ -33,8 +33,8 @@ public async Task ItemTest()
var value1 = Guid.NewGuid().ToString("N");
var value2 = Guid.NewGuid().ToString("N");

Assert.Null(await client.GetItem(key).ConfigureAwait(false));
Assert.False(await client.RemoveItem(key, "apollo").ConfigureAwait(false));
Assert.Null(await client.GetItem(key));
Assert.False(await client.RemoveItem(key, "apollo"));

try
{
Expand All @@ -43,31 +43,31 @@ public async Task ItemTest()
Key = key,
Value = value1,
DataChangeCreatedBy = "apollo"
}).ConfigureAwait(false);
});

Assert.NotNull(item);
Assert.NotNull(item.DataChangeLastModifiedTime);
Assert.NotNull(item.DataChangeCreatedBy);
Assert.Equal(value1, item.Value);

var item2 = await client.GetItem(key).ConfigureAwait(false);
var item2 = await client.GetItem(key);

Assert.NotNull(item2);
Assert.Equal(value1, item2!.Value);

item2.Value = value2;
item2.DataChangeLastModifiedBy = item2.DataChangeCreatedBy;

await client.UpdateItem(item2).ConfigureAwait(false);
await client.UpdateItem(item2);

item2 = await client.GetItem(key).ConfigureAwait(false);
item2 = await client.GetItem(key);

Assert.NotNull(item);
Assert.Equal(value2, item!.Value);
}
catch
{
Assert.True(await client.RemoveItem(key, "apollo").ConfigureAwait(false));
Assert.True(await client.RemoveItem(key, "apollo"));
}

key = Guid.NewGuid().ToString("N");
Expand All @@ -78,21 +78,21 @@ public async Task ItemTest()
Key = key,
Value = value1,
DataChangeCreatedBy = "apollo"
}).ConfigureAwait(false);
});

Assert.NotNull(item);
Assert.NotNull(item!.DataChangeLastModifiedTime);
Assert.NotNull(item.DataChangeCreatedBy);
Assert.Equal(value1, item.Value);

var item2 = await client.GetItem(key).ConfigureAwait(false);
var item2 = await client.GetItem(key);

Assert.NotNull(item2);
Assert.Equal(value1, item2!.Value);
}
catch
{
Assert.True(await client.RemoveItem(key, "apollo").ConfigureAwait(false));
Assert.True(await client.RemoveItem(key, "apollo"));
}
}

Expand All @@ -108,7 +108,7 @@ public async Task ReleaseTest()
ReleaseTitle = $"{DateTime.Now:yyyyMMddHHmmss}-release"
};

var result = await client.Publish(release).ConfigureAwait(false);
var result = await client.Publish(release);

Assert.NotNull(result);
Assert.Equal(client.AppId, result.AppId);
Expand All @@ -118,19 +118,19 @@ public async Task ReleaseTest()
Assert.NotNull(result.Configurations);
Assert.NotEmpty(result.Configurations!);

var latestActiveRelease = await client.GetLatestActiveRelease().ConfigureAwait(false);
var latestActiveRelease = await client.GetLatestActiveRelease();

Assert.NotNull(latestActiveRelease);

await client.Rollback("apollo", latestActiveRelease.Id).ConfigureAwait(false);
await client.Rollback("apollo", latestActiveRelease.Id);
}

[Fact]
public async Task ItemsTest()
{
var client = CreateNamespaceClient();

var result = await client.GetItems().ConfigureAwait(false);
var result = await client.GetItems();

Assert.True(result.Total > 0);

Expand Down
12 changes: 4 additions & 8 deletions test/Apollo.OpenApi.Tests/OpenApiFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public async Task ExceptionTest()
PortalUrl = new("http://81.68.181.139:8070"),
Token = Guid.NewGuid().ToString("N")
})
.CreateAppClusterClient("abc").GetAppInfo()
.ConfigureAwait(false);
.CreateAppClusterClient("abc").GetAppInfo();
}
catch (ApolloOpenApiException e)
{
Expand All @@ -33,8 +32,7 @@ public async Task ExceptionTest()
PortalUrl = new("http://81.68.181.139:8070"),
Token = "c18d0f7bc815c9e2d9699ee3216712a275b20a8d"
})
.CreateAppClusterClient("abc").GetAppInfo()
.ConfigureAwait(false);
.CreateAppClusterClient("abc").GetAppInfo();
}
catch (ApolloOpenApiException e)
{
Expand All @@ -49,8 +47,7 @@ public async Task ExceptionTest()
Token = "c18d0f7bc815c9e2d9699ee3216712a275b20a8d"
})
.CreateNamespaceClient("apollo.net", "PRO", "test", "test")
.GetNamespaceInfo()
.ConfigureAwait(false);
.GetNamespaceInfo();
}
catch (ApolloOpenApiException e)
{
Expand All @@ -65,8 +62,7 @@ public async Task ExceptionTest()
Token = "c18d0f7bc815c9e2d9699ee3216712a275b20a8d"
})
.CreateNamespaceClient("apollo.net", "DEV", "test", "test")
.GetNamespaceInfo()
.ConfigureAwait(false);
.GetNamespaceInfo();
}
catch (ApolloOpenApiException e)
{
Expand Down
8 changes: 4 additions & 4 deletions test/Apollo.Tests/ConfigServiceLocatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public async Task MetaServerTest()

var locator = new ConfigServiceLocator(new(options), options);

var services = await locator.GetConfigServices().ConfigureAwait(false);
var services = await locator.GetConfigServices();

Assert.Equal(1, services.Count);
Assert.Single(services);
Assert.Equal(options.MetaServer, services[0].HomepageUrl);
}

Expand All @@ -37,9 +37,9 @@ public async Task ConfigServerTest()

var locator = new ConfigServiceLocator(new(options), options);

var services = await locator.GetConfigServices().ConfigureAwait(false);
var services = await locator.GetConfigServices();

Assert.Equal(1, services.Count);
Assert.Single(services);
Assert.Equal(options.ConfigServer?.FirstOrDefault(), services[0].HomepageUrl);
}
}
12 changes: 6 additions & 6 deletions test/Apollo.Tests/ConfigTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task SingleNamespaceTest()
var repositoryFactory = new FakeConfigRepository(ConfigConsts.NamespaceApplication,
new(new Dictionary<string, string> { ["A"] = "3" }));

var config = await CreateConfig(repositoryFactory).ConfigureAwait(false);
var config = await CreateConfig(repositoryFactory);

Assert.Equal("3", config.GetProperty("A", ""));

Expand All @@ -25,7 +25,7 @@ public async Task SingleNamespaceTest()

repositoryFactory.Change(new(new Dictionary<string, string>()));

await Task.Delay(100).ConfigureAwait(false);
await Task.Delay(100);

Assert.NotNull(args);
}
Expand All @@ -41,7 +41,7 @@ public async Task MultipleNamespaceTest()
new(new Dictionary<string, string> {["B"] = "4"})),
};

var config = new MultiConfig(await Task.WhenAll(repositoryFactories.Select(CreateConfig).Reverse()).ConfigureAwait(false));
var config = new MultiConfig(await Task.WhenAll(repositoryFactories.Select(CreateConfig).Reverse()));

Assert.Equal("3", config.GetProperty("A", ""));
Assert.Equal("4", config.GetProperty("B", ""));
Expand All @@ -51,15 +51,15 @@ public async Task MultipleNamespaceTest()

repositoryFactories[1].Change(new(new Dictionary<string, string>()));

await Task.Delay(100).ConfigureAwait(false);
await Task.Delay(100);

Assert.NotNull(args);

args = null;

repositoryFactories[1].Change(new(new Dictionary<string, string> {["B"] = "3"}));

await Task.Delay(100).ConfigureAwait(false);
await Task.Delay(100);

Assert.Null(args);
}
Expand Down Expand Up @@ -88,4 +88,4 @@ public void Change(Properties properties)
FireRepositoryChange(Namespace, properties);
}
}
}
}
Loading