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

[repo/examples] Prepare to .NET9 #2251

Merged
merged 6 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 5 additions & 5 deletions examples/AspNet/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ namespace Examples.AspNet.Controllers;

public class WeatherForecastController : ApiController
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching",
};
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
];

[HttpGet] // For testing traditional routing. Ex: https://localhost:XXXX/api/weatherforecast
public async Task<IEnumerable<WeatherForecast>> Get()
Expand Down Expand Up @@ -89,7 +89,7 @@ public async Task<string> GetData()
[HttpPost]
public async Task<HttpResponseMessage> PostData()
{
string value1 = Baggage.GetBaggage("key1");
var value1 = Baggage.GetBaggage("key1");
if (string.IsNullOrEmpty(value1))
{
throw new InvalidOperationException("Key1 was not found on Baggage.");
Expand Down
2 changes: 1 addition & 1 deletion examples/enrichment/Examples.Enrichment/IMyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Examples.Enrichment;

public interface IMyService
internal interface IMyService
{
public (string Service, string Status) MyDailyStatus();
}
8 changes: 4 additions & 4 deletions examples/enrichment/Examples.Enrichment/MyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace Examples.Enrichment;

internal sealed class MyService : IMyService
{
private readonly List<string> statuses = new()
{
private readonly List<string> statuses =
[
"Blocked",
"No blockers",
"Out of office",
};
"Out of office"
];

/// <summary>
/// Returns daily status.
Expand Down
2 changes: 1 addition & 1 deletion examples/enrichment/Examples.Enrichment/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Examples.Enrichment;

public static class Program
internal static class Program
{
public static void Main()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ namespace Examples.GrpcCore.AspNetCore.Controllers;

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
internal class WeatherForecastController : ControllerBase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this. AspNetCore won't auto-register internal controller so this effectively breaks the app. Curious, what is the warning you are getting spurring this change?

Copy link
Contributor Author

@Kielek Kielek Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet format opentelemetry-dotnet-contrib.sln when executing in .NET9 SDK context (I just remove global.json file on my env).

It was one of the reasons to mark is as in progress - the second one, some differences in formatting between .NET8 (CI) and .NET9.

{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching",
};
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
];

private readonly Echo.EchoClient echoClient;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Examples.GrpcCore.AspNetCore;

public class Program
internal class Program
{
internal const int Port = 5000;
internal const int GrpcServicePort = 5001;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Examples.GrpcCore.AspNetCore;

public class Startup
internal class Startup
{
public Startup(IConfiguration configuration)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Examples.GrpcCore.AspNetCore;

public class WeatherForecast
internal class WeatherForecast
{
public WeatherForecast(DateTime date, int temperatureC, string summary)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/kafka/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Examples.ConfluentKafka;

public static class Constants
internal static class Constants
{
public static readonly string Topic = $"test-topic-{Guid.NewGuid()}";
}
12 changes: 6 additions & 6 deletions examples/kafka/ProduceConsumeHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@

namespace Examples.ConfluentKafka;

public class ProduceConsumeHostedService(
internal class ProduceConsumeHostedService(
InstrumentedProducerBuilder<string, string> instrumentedProducerBuilder,
InstrumentedConsumerBuilder<string, string> instrumentedConsumerBuilder)
: BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
IProducer<string, string> producer = instrumentedProducerBuilder.Build();
IConsumer<string, string> consumer = instrumentedConsumerBuilder.Build();
var producer = instrumentedProducerBuilder.Build();
var consumer = instrumentedConsumerBuilder.Build();

for (int j = 0; j < 100; j++)
for (var j = 0; j < 100; j++)
{
await producer.ProduceAsync(
Constants.Topic,
new Message<string, string> { Key = "any_key", Value = $"any_value_{j}" },
stoppingToken);
}

for (int j = 0; j < 100; j++)
for (var j = 0; j < 100; j++)
{
producer.Produce(
Constants.Topic,
Expand All @@ -35,7 +35,7 @@ await producer.ProduceAsync(
consumer.Subscribe(Constants.Topic);
while (!stoppingToken.IsCancellationRequested)
{
ConsumeResult<string, string> consumeResult = consumer.Consume(stoppingToken);
var consumeResult = consumer.Consume(stoppingToken);
if (consumeResult == null)
{
continue;
Expand Down
2 changes: 1 addition & 1 deletion examples/owin/Controllers/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Examples.Owin.Controllers;

public class TestController : ApiController
internal class TestController : ApiController
{
// GET api/test/{id}
public string Get(string? id = null)
Expand Down
2 changes: 1 addition & 1 deletion examples/process-instrumentation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using OpenTelemetry;
using OpenTelemetry.Metrics;

public class Program
internal class Program
{
public static void Main()
{
Expand Down
2 changes: 1 addition & 1 deletion examples/runtime-instrumentation/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using OpenTelemetry;
using OpenTelemetry.Metrics;

public class Program
internal class Program
{
public static void Main()
{
Expand Down
2 changes: 1 addition & 1 deletion examples/wcf/client-core/StatusServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Examples.Wcf.Client;

public class StatusServiceClient : ClientBase<IStatusServiceContract>, IStatusServiceContract
internal class StatusServiceClient : ClientBase<IStatusServiceContract>, IStatusServiceContract
{
public StatusServiceClient(string name)
: base(name)
Expand Down
2 changes: 1 addition & 1 deletion examples/wcf/client-netframework/StatusServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Examples.Wcf.Client;

public class StatusServiceClient : ClientBase<IStatusServiceContract>, IStatusServiceContract
internal class StatusServiceClient : ClientBase<IStatusServiceContract>, IStatusServiceContract
{
public StatusServiceClient(string name)
: base(name)
Expand Down
2 changes: 1 addition & 1 deletion examples/wcf/server-netframework/StatusService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Examples.Wcf.Server;
InstanceContextMode = InstanceContextMode.Single,
UseSynchronizationContext = false,
Name = "StatusService")]
public class StatusService : IStatusServiceContract
internal class StatusService : IStatusServiceContract
{
public Task<StatusResponse> PingAsync(StatusRequest request)
{
Expand Down
Loading