Skip to content

Commit

Permalink
Merge branch 'main' into pakrym/named
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym authored Dec 20, 2023
2 parents 1d082af + 0981bd7 commit b6ae751
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Jab/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Jab
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class ServiceProviderAttribute: Attribute
Expand All @@ -24,6 +25,7 @@ class ServiceProviderAttribute: Attribute
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class ServiceProviderModuleAttribute: Attribute
Expand All @@ -34,6 +36,7 @@ class ServiceProviderModuleAttribute: Attribute
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class ImportAttribute: Attribute
Expand All @@ -50,6 +53,7 @@ public ImportAttribute(Type moduleType)
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class SingletonAttribute: Attribute
Expand Down Expand Up @@ -80,6 +84,7 @@ public SingletonAttribute(Type serviceType, Type implementationType)
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class TransientAttribute : Attribute
Expand Down Expand Up @@ -107,6 +112,7 @@ public TransientAttribute(Type serviceType, Type implementationType)
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class ScopedAttribute : Attribute
Expand Down Expand Up @@ -152,6 +158,7 @@ public FromNamedServicesAttribute(string name)
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class ImportAttribute<TModule> : ImportAttribute
Expand All @@ -165,6 +172,7 @@ public ImportAttribute() : base(typeof(TModule))
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class TransientAttribute<TService> : TransientAttribute
Expand All @@ -178,6 +186,7 @@ public TransientAttribute() : base(typeof(TService))
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class TransientAttribute<TService, TImpl> : TransientAttribute where TImpl: TService
Expand All @@ -191,6 +200,7 @@ public TransientAttribute() : base(typeof(TService), typeof(TImpl))
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class ScopedAttribute<TService> : ScopedAttribute
Expand All @@ -204,6 +214,7 @@ public ScopedAttribute() : base(typeof(TService))
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class ScopedAttribute<TService, TImpl> : ScopedAttribute where TImpl: TService
Expand All @@ -218,6 +229,7 @@ public ScopedAttribute() : base(typeof(TService), typeof(TImpl))
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class SingletonAttribute<TService> : SingletonAttribute
Expand All @@ -231,6 +243,7 @@ public SingletonAttribute() : base(typeof(TService))
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
class SingletonAttribute<TService, TImpl> : SingletonAttribute where TImpl: TService
Expand All @@ -245,6 +258,7 @@ public SingletonAttribute() : base(typeof(TService), typeof(TImpl))
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
interface IServiceProvider<T>
Expand All @@ -255,6 +269,7 @@ interface IServiceProvider<T>
#if JAB_ATTRIBUTES_PACKAGE
public
#else
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Jab", null)]
internal
#endif
interface INamedServiceProvider<T>
Expand Down
4 changes: 4 additions & 0 deletions src/Jab/ContainerGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
public partial class ContainerGenerator : DiagnosticAnalyzer
#pragma warning restore RS1001 // We don't want this to be discovered as analyzer but it simplifies testing
{
/// <summary>Code for a [GeneratedCode] attribute to put on the top-level generated members.</summary>
private static readonly string _generatedCodeAttribute = $"[global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"{typeof(ContainerGenerator).Assembly.GetName().Name}\", \"{typeof(ContainerGenerator).Assembly.GetName().Version}\")]";

private void GenerateCallSiteWithCache(CodeWriter codeWriter, string rootReference, ServiceCallSite serviceCallSite, Action<CodeWriter, CodeWriterDelegate> valueCallback)
{
if (serviceCallSite is ErrorCallSite errorCallSite)
Expand Down Expand Up @@ -199,6 +202,7 @@ private void Execute(GeneratorContext context)
codeWriter.Scope($"{SyntaxFacts.GetText(containingType.DeclaredAccessibility)} partial class {containingType.Name}") :
null;

codeWriter.LineRaw(_generatedCodeAttribute);
codeWriter.Append($"{SyntaxFacts.GetText(root.Type.DeclaredAccessibility)} partial class {root.Type.Name}");
WriteInterfaces(codeWriter, root, false);
using (codeWriter.Scope())
Expand Down

0 comments on commit b6ae751

Please sign in to comment.