Skip to content

Commit 84af23f

Browse files
authored
feat: Add EmbeddedAttribute for source generation in ExportAllConstantSnippets (#242)
* feat: add EmbeddedAttribute for source generation in ExportAllConstantSnippets * fix: remove empty target framework entries from packages.lock.json
1 parent ca5f105 commit 84af23f

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/Linqraft.Analyzer/packages.lock.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@
260260
"Microsoft.CodeAnalysis.CSharp": "[4.11.0, )"
261261
}
262262
}
263-
},
264-
".NETStandard,Version=v2.0/win-x64": {}
263+
}
265264
}
266265
}

src/Linqraft.Core/GenerateSourceCodeSnippets.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static void ExportAllConstantSnippets(
1414
IncrementalGeneratorPostInitializationContext context
1515
)
1616
{
17+
context.AddSource("EmbeddedAttribute.g.cs", EmbeddedAttribute);
1718
context.AddSource("InterceptsLocationAttribute.g.cs", InterceptsLocationAttribute);
1819
context.AddSource("SelectExprExtensions.g.cs", SelectExprExtensions);
1920
context.AddSource(
@@ -174,17 +175,30 @@ public static string BuildDtoCodeAttributes()
174175
""";
175176
}
176177

178+
[StringSyntax("csharp")]
179+
public const string EmbeddedAttribute = $$"""
180+
{{CommentHeaderPartOnProd}}
181+
namespace Microsoft.CodeAnalysis
182+
{
183+
internal sealed partial class EmbeddedAttribute : global::System.Attribute
184+
{
185+
}
186+
}
187+
""";
188+
177189
[StringSyntax("csharp")]
178190
public const string InterceptsLocationAttribute = $$"""
179191
{{CommentHeaderPartOnProd}}
180192
#nullable enable
181193
using System;
182194
using System.ComponentModel;
195+
using Microsoft.CodeAnalysis;
183196
184197
namespace System.Runtime.CompilerServices
185198
{
186199
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
187200
[EditorBrowsable(EditorBrowsableState.Never)]
201+
[EmbeddedAttribute]
188202
internal sealed class InterceptsLocationAttribute : Attribute
189203
{
190204
public InterceptsLocationAttribute(int version, string data)
@@ -209,11 +223,13 @@ public InterceptsLocationAttribute(int version, string data)
209223
#nullable enable
210224
using System;
211225
using System.ComponentModel;
226+
using Microsoft.CodeAnalysis;
212227
213228
namespace Linqraft
214229
{
215230
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
216231
[EditorBrowsable(EditorBrowsableState.Never)]
232+
[EmbeddedAttribute]
217233
internal sealed class LinqraftAutoGeneratedDtoAttribute : Attribute
218234
{
219235
}

src/Linqraft.Core/packages.lock.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@
127127
"System.Runtime.CompilerServices.Unsafe": "4.5.3"
128128
}
129129
}
130-
},
131-
".NETStandard,Version=v2.0/win-x64": {}
130+
}
132131
}
133132
}

src/Linqraft.SourceGenerator/packages.lock.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134
"Microsoft.CodeAnalysis.CSharp": "[4.11.0, )"
135135
}
136136
}
137-
},
138-
".NETStandard,Version=v2.0/win-x64": {}
137+
}
139138
}
140139
}

0 commit comments

Comments
 (0)