Skip to content

Commit 2a97920

Browse files
authored
Fix IDE0090: 'new' expression can be simplified. (#3012)
* Set rule for new() usage. * Fix IDE0090 "'new' expression can be simplified"
1 parent 7b19794 commit 2a97920

File tree

108 files changed

+183
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+183
-182
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ csharp_prefer_braces = true:silent
6565
csharp_preserve_single_line_blocks = true
6666
csharp_preserve_single_line_statements = true
6767
dotnet_style_readonly_field = true:suggestion
68+
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
6869

6970
# Expression-level preferences
7071
dotnet_style_object_initializer = true:suggestion

docs/metrics/customizing-the-sdk/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
public class Program
2323
{
24-
private static readonly Meter Meter1 = new Meter("CompanyA.ProductA.Library1", "1.0");
25-
private static readonly Meter Meter2 = new Meter("CompanyA.ProductB.Library2", "1.0");
24+
private static readonly Meter Meter1 = new("CompanyA.ProductA.Library1", "1.0");
25+
private static readonly Meter Meter2 = new("CompanyA.ProductB.Library2", "1.0");
2626

2727
public static void Main(string[] args)
2828
{

docs/metrics/extending-the-sdk/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
public class Program
2525
{
26-
private static readonly Meter MyMeter = new Meter("MyCompany.MyProduct.MyLibrary", "1.0");
26+
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
2727
private static readonly Counter<long> MyFruitCounter = MyMeter.CreateCounter<long>("MyFruitCounter");
2828

2929
static Program()

docs/metrics/getting-started-prometheus-grafana/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public class Program
2424
{
25-
private static readonly Meter MyMeter = new Meter("MyCompany.MyProduct.MyLibrary", "1.0");
25+
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
2626
private static readonly Counter<long> MyFruitCounter = MyMeter.CreateCounter<long>("MyFruitCounter");
2727

2828
public static void Main(string[] args)

docs/metrics/getting-started/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public class Program
2222
{
23-
private static readonly Meter MyMeter = new Meter("MyCompany.MyProduct.MyLibrary", "1.0");
23+
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
2424
private static readonly Counter<long> MyFruitCounter = MyMeter.CreateCounter<long>("MyFruitCounter");
2525

2626
public static void Main(string[] args)

docs/metrics/learning-more-instruments/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
public class Program
2525
{
26-
private static readonly Meter MyMeter = new Meter("MyCompany.MyProduct.MyLibrary", "1.0");
26+
private static readonly Meter MyMeter = new("MyCompany.MyProduct.MyLibrary", "1.0");
2727
private static readonly Histogram<long> MyHistogram = MyMeter.CreateHistogram<long>("MyHistogram");
2828

2929
static Program()

docs/trace/customizing-the-sdk/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020

2121
public class Program
2222
{
23-
private static readonly ActivitySource MyLibraryActivitySource = new ActivitySource(
23+
private static readonly ActivitySource MyLibraryActivitySource = new(
2424
"MyCompany.MyProduct.MyLibrary");
2525

26-
private static readonly ActivitySource ComponentAActivitySource = new ActivitySource(
26+
private static readonly ActivitySource ComponentAActivitySource = new(
2727
"AbcCompany.XyzProduct.ComponentA");
2828

29-
private static readonly ActivitySource ComponentBActivitySource = new ActivitySource(
29+
private static readonly ActivitySource ComponentBActivitySource = new(
3030
"AbcCompany.XyzProduct.ComponentB");
3131

32-
private static readonly ActivitySource SomeOtherActivitySource = new ActivitySource(
32+
private static readonly ActivitySource SomeOtherActivitySource = new(
3333
"SomeCompany.SomeProduct.SomeComponent");
3434

3535
public static void Main()

docs/trace/extending-the-sdk/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
public class Program
2323
{
24-
private static readonly ActivitySource DemoSource = new ActivitySource("OTel.Demo");
24+
private static readonly ActivitySource DemoSource = new("OTel.Demo");
2525

2626
public static void Main()
2727
{

docs/trace/getting-started/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public class Program
2222
{
23-
private static readonly ActivitySource MyActivitySource = new ActivitySource(
23+
private static readonly ActivitySource MyActivitySource = new(
2424
"MyCompany.MyProduct.MyLibrary");
2525

2626
public static void Main()

docs/trace/reporting-exceptions/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
public class Program
2323
{
24-
private static readonly ActivitySource MyActivitySource = new ActivitySource(
24+
private static readonly ActivitySource MyActivitySource = new(
2525
"MyCompany.MyProduct.MyLibrary");
2626

2727
public static void Main()

0 commit comments

Comments
 (0)