Skip to content

Commit 90b853b

Browse files
committed
Added stuff to the generated attributes based on code analysis rules
1 parent f9f356d commit 90b853b

File tree

53 files changed

+159
-106
lines changed

Some content is hidden

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

53 files changed

+159
-106
lines changed

src/PublicInterfaceGenerator/AttributeGenerationHelper.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static string GenerateEmbeddedAttribute()
2929
"""
3030
namespace Microsoft.CodeAnalysis
3131
{
32+
[System.AttributeUsage(System.AttributeTargets.All)]
3233
internal sealed class EmbeddedAttribute : System.Attribute {}
3334
}
3435
""";
@@ -42,7 +43,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
4243
{
4344
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
4445
[Microsoft.CodeAnalysis.EmbeddedAttribute]
45-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
46+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
4647
{
4748
}
4849
}
@@ -56,7 +57,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
5657
{
5758
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
5859
[Microsoft.CodeAnalysis.EmbeddedAttribute]
59-
public class GenerateInterfaceAttribute : System.Attribute
60+
public sealed class GenerateInterfaceAttribute : System.Attribute
6061
{
6162
/// <summary>
6263
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/Events/EventsTests.ActionEvents_AssertResults#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/Events/EventsTests.CustomEvents_AssertResults#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/Events/EventsTests.EventWithComments_AssertCommentsAppearInGeneratedInterfaceEvents#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/Events/EventsTests.ImplementsInterfaceEvent_AssertEventNotInGeneratedInterface#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/Events/EventsTests.SelfReferentialSenderEvent_AssertOutput#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/Events/EventsTests.SimpleEvents_AssertResults#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/Events/EventsTests.WithExcludedEvents_AssertResults#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/InterfaceDefinitionTests/InterfaceDefinitionTests.CustomInterfaces#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

src/UnitTests/Snapshots/InterfaceDefinitionTests/InterfaceDefinitionTests.CustomInterfacesAndIAsyncDisposable#PublicInterfaceGeneratorAttributes.verified.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//HintName: PublicInterfaceGeneratorAttributes.cs
22
namespace Microsoft.CodeAnalysis
33
{
4+
[System.AttributeUsage(System.AttributeTargets.All)]
45
internal sealed class EmbeddedAttribute : System.Attribute {}
56
}
67

78
namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
89
{
910
[System.AttributeUsage(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Event, Inherited = false, AllowMultiple = false)]
1011
[Microsoft.CodeAnalysis.EmbeddedAttribute]
11-
public class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
12+
public sealed class ExcludeFromGeneratedInterfaceAttribute : System.Attribute
1213
{
1314
}
1415
}
@@ -17,7 +18,7 @@ namespace ProgrammerAl.SourceGenerators.PublicInterfaceGenerator.Attributes
1718
{
1819
[System.AttributeUsage(System.AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
1920
[Microsoft.CodeAnalysis.EmbeddedAttribute]
20-
public class GenerateInterfaceAttribute : System.Attribute
21+
public sealed class GenerateInterfaceAttribute : System.Attribute
2122
{
2223
/// <summary>
2324
/// Set this to override the default interface name. Or leave it null to use the class name with an 'I' prepended to it.

0 commit comments

Comments
 (0)