|
1 | 1 | using Microsoft.CodeAnalysis; |
| 2 | +using Microsoft.CodeAnalysis.CSharp; |
2 | 3 | using TrProtocol.Attributes; |
3 | 4 | using TrProtocol.Interfaces; |
4 | 5 | using TrProtocol.SerializerGenerator.Internal.Diagnostics; |
@@ -81,6 +82,58 @@ public static ProtocolTypeData BuildProtocolTypeInfo(CompilationContext context, |
81 | 82 | model.HasExtraData = true; |
82 | 83 | } |
83 | 84 |
|
| 85 | + if (modelSym.AllInterfaces.Any(i => i.Name == nameof(INonSideSpecific))) { |
| 86 | + var location = baseList!.GetLocation(); |
| 87 | + var foundInterface = baseList!.Types.First(t => t.ToString() == nameof(INonSideSpecific)); |
| 88 | + if (foundInterface is not null) { |
| 89 | + location = foundInterface.GetLocation(); |
| 90 | + } |
| 91 | + throw new DiagnosticException( |
| 92 | + Diagnostic.Create( |
| 93 | + new DiagnosticDescriptor( |
| 94 | + "SCG32", |
| 95 | + "Do not manually implement INonSideSpecific", |
| 96 | + "The interface 'INonSideSpecific' is automatically provided by the source generator. Do not declare it explicitly in the inheritance list.", |
| 97 | + "SourceGeneration", |
| 98 | + DiagnosticSeverity.Error, |
| 99 | + true), |
| 100 | + location)); |
| 101 | + } |
| 102 | + if (modelSym.AllInterfaces.Any(i => i.Name == nameof(INonLengthAware))) { |
| 103 | + var location = baseList!.GetLocation(); |
| 104 | + var foundInterface = baseList!.Types.First(t => t.ToString() == nameof(INonLengthAware)); |
| 105 | + if (foundInterface is not null) { |
| 106 | + location = foundInterface.GetLocation(); |
| 107 | + } |
| 108 | + throw new DiagnosticException( |
| 109 | + Diagnostic.Create( |
| 110 | + new DiagnosticDescriptor( |
| 111 | + "SCG32", |
| 112 | + "Do not manually implement INonLengthAware", |
| 113 | + "The interface 'INonLengthAware' is automatically provided by the source generator. Do not declare it explicitly in the inheritance list.", |
| 114 | + "SourceGeneration", |
| 115 | + DiagnosticSeverity.Error, |
| 116 | + true), |
| 117 | + location)); |
| 118 | + } |
| 119 | + if (modelSym.AllInterfaces.Any(i => i.Name == nameof(IManagedPacket))) { |
| 120 | + var location = baseList!.GetLocation(); |
| 121 | + var foundInterface = baseList!.Types.First(t => t.ToString() == nameof(IManagedPacket)); |
| 122 | + if (foundInterface is not null) { |
| 123 | + location = foundInterface.GetLocation(); |
| 124 | + } |
| 125 | + throw new DiagnosticException( |
| 126 | + Diagnostic.Create( |
| 127 | + new DiagnosticDescriptor( |
| 128 | + "SCG32", |
| 129 | + "Do not manually implement IManagedPacket", |
| 130 | + "The interface 'IManagedPacket' is automatically provided by the source generator. Do not declare it explicitly in the inheritance list.", |
| 131 | + "SourceGeneration", |
| 132 | + DiagnosticSeverity.Error, |
| 133 | + true), |
| 134 | + location)); |
| 135 | + } |
| 136 | + |
84 | 137 | if (modelSym.AllInterfaces.Any(i => i.Name == nameof(ISideSpecific))) { |
85 | 138 | model.IsSideSpecific = true; |
86 | 139 | } |
|
0 commit comments