Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<PackageTags>system.reactive;splat;dependency injection</PackageTags>
<PackageReleaseNotes>https://github.com/reactivemarbles/Splat.DI.SourceGenerator/releases</PackageReleaseNotes>
<RepositoryUrl>https://github.com/reactivemarbles/Splat.DI.SourceGenerator</RepositoryUrl>
<PackageIconUrl>https://github.com/reactiveui/styleguide/blob/master/logo_splat/logo.png?raw=true</PackageIconUrl>
<RepositoryType>git</RepositoryType>

<!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
Expand All @@ -22,12 +21,17 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<PackageIcon>logo.png</PackageIcon>
</PropertyGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true'">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\logo.png" Pack="true" PackagePath="" />
</ItemGroup>

<PropertyGroup>
<SolutionDir Condition="'$(SolutionDir)' == ''">$(MSBuildThisFileDirectory)</SolutionDir>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,58)-(22,61),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,58)-(22,61),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,58)-(22,61),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,63)-(22,66),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,63)-(22,66),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,63)-(22,66),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (23,15)-(23,27),
MessageFormat: One one constructor should be marked with the DependencyInjectionConstructorAttribute attribute,
MessageFormat: {0} has multiple constructors marked with the DependencyInjectionConstructorAttribute attribute change so only one is marked,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (23,15)-(23,27),
MessageFormat: One one constructor should be marked with the DependencyInjectionConstructorAttribute attribute,
MessageFormat: {0} has multiple constructors marked with the DependencyInjectionConstructorAttribute attribute change so only one is marked,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (23,15)-(23,27),
MessageFormat: One one constructor should be marked with the DependencyInjectionConstructorAttribute attribute,
MessageFormat: {0} has multiple constructors marked with the DependencyInjectionConstructorAttribute attribute change so only one is marked,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (10,12)-(10,75),
MessageFormat: There are more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
MessageFormat: {0} has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (10,12)-(10,82),
MessageFormat: There are more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
MessageFormat: {0} has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (10,12)-(10,82),
MessageFormat: There are more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
MessageFormat: {0} has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,58)-(22,61),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,58)-(22,61),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,58)-(22,61),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,63)-(22,66),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,63)-(22,66),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (22,63)-(22,66),
MessageFormat: DependencyInjectionPropertyAttribute property must have a public or internal setter,
MessageFormat: {0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (23,15)-(23,27),
MessageFormat: One one constructor should be marked with the DependencyInjectionConstructorAttribute attribute,
MessageFormat: {0} has multiple constructors marked with the DependencyInjectionConstructorAttribute attribute change so only one is marked,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (23,15)-(23,27),
MessageFormat: One one constructor should be marked with the DependencyInjectionConstructorAttribute attribute,
MessageFormat: {0} has multiple constructors marked with the DependencyInjectionConstructorAttribute attribute change so only one is marked,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (23,15)-(23,27),
MessageFormat: One one constructor should be marked with the DependencyInjectionConstructorAttribute attribute,
MessageFormat: {0} has multiple constructors marked with the DependencyInjectionConstructorAttribute attribute change so only one is marked,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (10,12)-(10,62),
MessageFormat: There are more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
MessageFormat: {0} has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (10,12)-(10,69),
MessageFormat: There are more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
MessageFormat: {0} has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Severity: Error,
WarningLevel: 0,
Location: : (10,12)-(10,69),
MessageFormat: There are more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
MessageFormat: {0} has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute,
Category: Compiler
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);SA1600</NoWarn>
<NoWarn>$(NoWarn);SA1600;CS1591</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -19,7 +19,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Verify.SourceGenerators" Version="1.0.0" />
<PackageReference Include="Verify.SourceGenerators" Version="1.0.1" />
<PackageReference Include="ReactiveMarbles.SourceGenerator.TestNuGetHelper" Version="1.0.8" />
<PackageReference Include="Verify.Xunit" Version="11.20.3" />
<PackageRefernece Include="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" PrivateAssets="all" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ protected Task TestPass(string source, string contractParameter, [CallerFilePath
var driver = Generate(source);
VerifySettings settings = new();
settings.UseParameters(contractParameter);
settings.AutoVerify();

return Verifier.Verify(driver, settings, sourceFile: file);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Release 1.0

### New Rules

Rule ID | Category | Severity | Notes
------------|----------|----------|--------------------
SPLATDI001 | Design | Error |
SPLATDI002 | Design | Error |
SPLATDI003 | Design | Error |
SPLATDI004 | Design | Error |
SPLATDI005 | Design | Error |
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@ namespace Splat.DependencyInjection.SourceGenerator
{
internal static class DiagnosticWarnings
{
internal static readonly DiagnosticDescriptor ExpressionMustBeInline = new(
internal static readonly DiagnosticDescriptor MultipleConstructorNeedAttribute = new(
id: "SPLATDI001",
title: "Can't find valid constructor",
messageFormat: "There are more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute",
messageFormat: "{0} has more than one constructor and one hasn't been marked with DependencyInjectionConstructorAttribute",
category: "Compiler",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);

internal static readonly DiagnosticDescriptor PropertyMustPublicBeSettable = new(
id: "SPLATDI002",
title: "Property must be public/internal settable",
messageFormat: "DependencyInjectionPropertyAttribute property must have a public or internal setter",
messageFormat: "{0} property marked with DependencyInjectionPropertyAttribute must have a public or internal setter",
category: "Compiler",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);

internal static readonly DiagnosticDescriptor MultipleConstructorsMarked = new(
id: "SPLATDI003",
title: "Multiple constructors have DependencyInjectionConstructorAttribute",
messageFormat: "One one constructor should be marked with the DependencyInjectionConstructorAttribute attribute",
messageFormat: "{0} has multiple constructors marked with the DependencyInjectionConstructorAttribute attribute change so only one is marked",
category: "Compiler",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);

internal static readonly DiagnosticDescriptor ConstructorsMustBePublic = new(
id: "SPLATDI004",
title: "Constructors not public or internal",
messageFormat: "Constructor declared with DependencyInjectionConstructorAttribute attribute must be public or internal",
messageFormat: "{0} constructor declared with DependencyInjectionConstructorAttribute attribute must be public or internal",
category: "Compiler",
defaultSeverity: DiagnosticSeverity.Error,
isEnabledByDefault: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

namespace Splat.DependencyInjection.SourceGenerator.Metadata
{
public record ParameterMetadata(string ParameterName, string ParameterValue);
internal record ParameterMetadata(string ParameterName, string ParameterValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private static IEnumerable<ConstructorDependencyMetadata> GetConstructorDependen
{
if (returnConstructor != null)
{
throw new ContextDiagnosticException(Diagnostic.Create(DiagnosticWarnings.MultipleConstructorsMarked, constructor.Locations.FirstOrDefault()));
throw new ContextDiagnosticException(Diagnostic.Create(DiagnosticWarnings.MultipleConstructorsMarked, constructor.Locations.FirstOrDefault(), concreteTarget.ToDisplayString(RoslynCommonHelpers.TypeFormat)));
}

returnConstructor = constructor;
Expand All @@ -150,12 +150,12 @@ private static IEnumerable<ConstructorDependencyMetadata> GetConstructorDependen

if (returnConstructor is null)
{
throw new ContextDiagnosticException(Diagnostic.Create(DiagnosticWarnings.ExpressionMustBeInline, invocationExpression.GetLocation()));
throw new ContextDiagnosticException(Diagnostic.Create(DiagnosticWarnings.MultipleConstructorNeedAttribute, invocationExpression.GetLocation(), concreteTarget.ToDisplayString(RoslynCommonHelpers.TypeFormat)));
}

if (returnConstructor.DeclaredAccessibility < Accessibility.Internal)
{
throw new ContextDiagnosticException(Diagnostic.Create(DiagnosticWarnings.ConstructorsMustBePublic, returnConstructor.Locations.FirstOrDefault()));
throw new ContextDiagnosticException(Diagnostic.Create(DiagnosticWarnings.ConstructorsMustBePublic, returnConstructor.Locations.FirstOrDefault(), concreteTarget.ToDisplayString(RoslynCommonHelpers.TypeFormat)));
}

return returnConstructor.Parameters.Select(x => new ConstructorDependencyMetadata(x, x.Type));
Expand All @@ -174,7 +174,7 @@ private static IEnumerable<PropertyDependencyMetadata> GetPropertyDependencies(I
{
if (property.SetMethod?.DeclaredAccessibility < Accessibility.Internal)
{
throw new ContextDiagnosticException(Diagnostic.Create(DiagnosticWarnings.PropertyMustPublicBeSettable, property.SetMethod?.Locations.FirstOrDefault()));
throw new ContextDiagnosticException(Diagnostic.Create(DiagnosticWarnings.PropertyMustPublicBeSettable, property.SetMethod?.Locations.FirstOrDefault(), property.ToDisplayString(RoslynCommonHelpers.TypeFormat)));
}

yield return new PropertyDependencyMetadata(property);
Expand Down