generated from VeyronSakai/RoslynAnalyzerTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from VeyronSakai/feature/use-entrypoints
Added Analyzer for UseEntryPoints
- Loading branch information
Showing
6 changed files
with
150 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
VContainerAnalyzer.Test/TestData/AddConstructorWithoutInjectAttributeClassLifetimeScope.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) 2020-2024 VeyronSakai. | ||
// This software is released under the MIT License. | ||
|
||
using VContainer; | ||
using VContainer.Unity; | ||
|
||
namespace VContainerAnalyzer.Test.TestData | ||
{ | ||
public class AddConstructorWithoutInjectAttributeClassLifetimeScope | ||
{ | ||
// ReSharper disable once UnusedMember.Global | ||
public void Configure(IContainerBuilder builder) | ||
{ | ||
builder.UseEntryPoints(Lifetime.Singleton, entryPoints => | ||
{ | ||
entryPoints.Add<ConstructorWithoutInjectAttributeClass>(); | ||
}); | ||
} | ||
} | ||
} |
26 changes: 25 additions & 1 deletion
26
VContainerAnalyzer.Test/TestData/VContainer/ContainerBuilderUnityExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,40 @@ | ||
// Copyright (c) 2020-2024 VeyronSakai. | ||
// This software is released under the MIT License. | ||
|
||
// ReSharper disable once CheckNamespace | ||
using System; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace VContainer.Unity | ||
{ | ||
public readonly struct EntryPointsBuilder | ||
{ | ||
private readonly IContainerBuilder _containerBuilder; | ||
private readonly Lifetime _lifetime; | ||
|
||
// ReSharper disable once ConvertToPrimaryConstructor | ||
public EntryPointsBuilder(IContainerBuilder containerBuilder, Lifetime lifetime) | ||
{ | ||
this._containerBuilder = containerBuilder; | ||
this._lifetime = lifetime; | ||
} | ||
|
||
public RegistrationBuilder Add<T>() => _containerBuilder.Register<T>(_lifetime).AsImplementedInterfaces(); | ||
} | ||
|
||
public static class ContainerBuilderUnityExtensions | ||
{ | ||
public static RegistrationBuilder RegisterEntryPoint<T>(this IContainerBuilder builder, | ||
Lifetime lifetime = Lifetime.Singleton) | ||
{ | ||
return new RegistrationBuilder(); | ||
} | ||
|
||
public static void UseEntryPoints( | ||
this IContainerBuilder builder, | ||
Lifetime lifetime, | ||
Action<EntryPointsBuilder> configuration) | ||
{ | ||
configuration(new EntryPointsBuilder(builder, lifetime)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters