Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue / Better Analyzer #118

Merged
merged 12 commits into from
Apr 1, 2024
311 changes: 307 additions & 4 deletions .editorconfig

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>../../../stylecop.ruleset</CodeAnalysisRuleSet>
<AnalysisModeStyle>All</AnalysisModeStyle>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<None Include="..\..\..\icon.png" Pack="true" PackagePath="\" />
<None Include="..\..\..\LICENSE" Pack="true" PackagePath="\" />
<None Include="..\..\..\README.md" Pack="true" PackagePath="\" />
<None Include="..\..\..\stylecop.ruleset" Pack="true" PackagePath="\" />
<None Include="..\..\..\.editorconfig" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class BusinessExtensions
throw new Exception("AddScopedWithFactory<TService, TImplementation> should have existed");

public static IServiceCollection AddTransientWithFactory(this IServiceCollection source, Type service) =>
(IServiceCollection?)_addTransientWithFactory.MakeGenericMethod(service, service).Invoke(null, new object[] { source }) ??
(IServiceCollection?)_addTransientWithFactory.MakeGenericMethod(service, service).Invoke(null, [source]) ??
throw new("Should've returned an IServiceCollection instance");
public static IServiceCollection AddTransientWithFactory(this IServiceCollection source, Type service, Type implementation) =>
(IServiceCollection?)_addTransientWithFactory.MakeGenericMethod(service, implementation).Invoke(null, [source]) ??
Expand All @@ -33,7 +33,7 @@ public static IServiceCollection AddTransientWithFactory<TService, TImplementati
.AddTransient<TService, TImplementation>();

public static IServiceCollection AddScopedWithFactory(this IServiceCollection source, Type service) =>
(IServiceCollection?)_addScopedWithFactory.MakeGenericMethod(service, service).Invoke(null, new object[] { source }) ??
(IServiceCollection?)_addScopedWithFactory.MakeGenericMethod(service, service).Invoke(null, [source]) ??
throw new("Should've returned an IServiceCollection instance");
public static IServiceCollection AddScopedWithFactory(this IServiceCollection source, Type service, Type implementation) =>
(IServiceCollection?)_addScopedWithFactory.MakeGenericMethod(service, implementation).Invoke(null, [source]) ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Do.Business.Default;
public class DefaultBusinessFeature(List<Assembly> _assemblies, Assembly _controllerAssembly)
: IFeature<BusinessConfigurator>
{
const BindingFlags _defaultMemberBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;
const BindingFlags DefaultMemberBindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly;

public void Configure(LayerConfigurator configurator)
{
Expand All @@ -22,9 +22,9 @@ public void Configure(LayerConfigurator configurator)

configurator.ConfigureDomainBuilderOptions(options =>
{
options.ConstuctorBindingFlags = _defaultMemberBindingFlags;
options.MethodBindingFlags = _defaultMemberBindingFlags;
options.PropertyBindingFlags = _defaultMemberBindingFlags;
options.ConstuctorBindingFlags = DefaultMemberBindingFlags;
options.MethodBindingFlags = DefaultMemberBindingFlags;
options.PropertyBindingFlags = DefaultMemberBindingFlags;
});

configurator.ConfigureServiceCollection(services =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Do.Configuration;

public class ConfigurationRequiredException(string _key)
: Exception($"Configuration required for {_key}") { }
: Exception($"Configuration required for {_key}")
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public void Apply(OpenApiSchema model, SchemaFilterContext context)
foreach (var enumName in Enum.GetNames(context.Type))
{
var memberInfo = context.Type.GetMember(enumName).FirstOrDefault(m => m.DeclaringType == context.Type);
var enumMemberAttribute = memberInfo == null
? null
: memberInfo.GetCustomAttributes(typeof(EnumMemberAttribute), false).OfType<EnumMemberAttribute>().FirstOrDefault();
var enumMemberAttribute = memberInfo?.GetCustomAttributes(typeof(EnumMemberAttribute), false).OfType<EnumMemberAttribute>().FirstOrDefault();

var label = enumMemberAttribute == null || string.IsNullOrWhiteSpace(enumMemberAttribute.Value)
? enumName
Expand All @@ -30,4 +28,4 @@ public void Apply(OpenApiSchema model, SchemaFilterContext context)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,4 @@
<Using Include="Do" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)../stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers.Unstable" VersionOverride="1.2.0.556" Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
15 changes: 0 additions & 15 deletions src/blueprints/Do.Blueprints.Service/do-blueprints-service.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,4 @@
<Using Include="System.Threading.Tasks" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)../stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers.Unstable" VersionOverride="1.2.0.556" Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public class CannotProceedException(IEnumerable<IPhase> _phases)
"Cannot proceed to run the application. " +
$"Phases ({string.Join(", ", _phases.Select(p => p.GetType().Name))}) " +
"won't get ready for initialization."
) { }
)
{ }
2 changes: 1 addition & 1 deletion src/core/Do.Architecture/Architecture/LayerConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ record Target(Type Type, object Value);
LayerConfigurator(ApplicationContext context, params Target[] targets)
{
_context = context;
_targets = [..targets];
_targets = [.. targets];
}

public ApplicationContext Context => _context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public class OverlappingPhaseException(PhaseOrder _order, IEnumerable<IPhase> _p
$"More than one phase cannot have '{_order}' at the same time. " +
"Change the order of phases. Overlapping phases are: " +
$"{string.Join(", ", _phases.Where(p => p.Order == _order).Select(p => p.GetType().Name))}"
) { }
)
{ }
2 changes: 1 addition & 1 deletion src/core/Do.Architecture/Architecture/PhaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class PhaseContext(IEnumerable<LayerConfigurator> configurators)
{
public static readonly PhaseContext Empty = new([]);

public IEnumerable<LayerConfigurator> Configurators { get; } = [..configurators];
public IEnumerable<LayerConfigurator> Configurators { get; } = [.. configurators];
public Action? OnDispose { get; init; }

void IDisposable.Dispose() => OnDispose?.Invoke();
Expand Down
15 changes: 0 additions & 15 deletions src/core/Do.Architecture/do-architecture.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,4 @@
<Using Include="Do" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)../stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers.Unstable" VersionOverride="1.2.0.556" Condition="'$(ManagePackageVersionsCentrally)' == 'true'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" Condition="'$(ManagePackageVersionsCentrally)' != 'true'">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
204 changes: 0 additions & 204 deletions stylecop.ruleset

This file was deleted.

Loading