diff --git a/src/AutoFactories.Tests/AutoFactories.Tests.csproj b/src/AutoFactories.Tests/AutoFactories.Tests.csproj
index 36f3245..cba2c72 100644
--- a/src/AutoFactories.Tests/AutoFactories.Tests.csproj
+++ b/src/AutoFactories.Tests/AutoFactories.Tests.csproj
@@ -15,8 +15,8 @@
-
-
+
+
all
diff --git a/src/AutoFactories.Tests/DiagnosticsTests.cs b/src/AutoFactories.Tests/DiagnosticsTests.cs
index ed3f95e..d891496 100644
--- a/src/AutoFactories.Tests/DiagnosticsTests.cs
+++ b/src/AutoFactories.Tests/DiagnosticsTests.cs
@@ -26,7 +26,7 @@ public class Human
""",
assertAnalyzerResult: d => d.Should()
- .OnlyContain(d => d.Id == DiagnosticIdentifier.ExposedAsIsNotDerivedType));
+ .OnlyContain(d => d.Id == DiagnosticIdentifier.ExposedAsIsNotDerivedType.Value));
[Fact]
@@ -57,7 +57,7 @@ public UntaggedFactory([FromFactory] string name)
{}
}
""",
- assertAnalyzerResult: d => d.Should().OnlyContain(d => d.Id == DiagnosticIdentifier.UnmarkedFactory));
+ assertAnalyzerResult: d => d.Should().OnlyContain(d => d.Id == DiagnosticIdentifier.UnmarkedFactory.Value));
public Task PublicFactory_WithInternalClass_EmitsInconsistentFactoryAccessibility()
=> Compose($$"""
@@ -71,7 +71,7 @@ internal class Chair
{}
""",
assertAnalyzerResult: d => d.Should()
- .OnlyContain(d => d.Id == DiagnosticIdentifier.InconsistentFactoryAccessibility));
+ .OnlyContain(d => d.Id == DiagnosticIdentifier.InconsistentFactoryAccessibility.Value));
[Fact]
public Task Parameter_With_Unresolved_Type_EmitsUnresolvedParameterType()
@@ -98,7 +98,7 @@ public Provider(IExternalType externalType)
}
""",
assertAnalyzerResult:
- d => d.Should().OnlyContain(d => d.Id == DiagnosticIdentifier.UnresolvedParameterType));
+ d => d.Should().OnlyContain(d => d.Id == DiagnosticIdentifier.UnresolvedParameterType.Value));
}
}
}
diff --git a/src/AutoFactories/AutoFactories.csproj b/src/AutoFactories/AutoFactories.csproj
index f4d7457..e432a10 100644
--- a/src/AutoFactories/AutoFactories.csproj
+++ b/src/AutoFactories/AutoFactories.csproj
@@ -1,10 +1,11 @@
-
+
12
true
True
Icon.jpg
+ true
@@ -14,17 +15,9 @@
True
\
-
-
-
-
-
-
-
-
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -32,23 +25,15 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
+
+
+
+
+
diff --git a/src/AutoFactories/Diagnostics/DiagnosticBuilder.cs b/src/AutoFactories/Diagnostics/DiagnosticBuilder.cs
index 262981a..c9f682d 100644
--- a/src/AutoFactories/Diagnostics/DiagnosticBuilder.cs
+++ b/src/AutoFactories/Diagnostics/DiagnosticBuilder.cs
@@ -59,7 +59,7 @@ protected DiagnosticBuilder(DiagnosticIdentifier id, string title, string catego
///
///
protected virtual DiagnosticDescriptor CreateDescriptor()
- => new DiagnosticDescriptor(Id, Title, MessageFormat, Category, Severity, true, Description);
+ => new DiagnosticDescriptor(Id.Value, Title, MessageFormat, Category, Severity, true, Description);
protected static string FormatId(int number)
=> $"AF{number + 100}";
diff --git a/src/AutoFactories/Diagnostics/DiagnosticIdentifier.cs b/src/AutoFactories/Diagnostics/DiagnosticIdentifier.cs
index 9eabf83..851c380 100644
--- a/src/AutoFactories/Diagnostics/DiagnosticIdentifier.cs
+++ b/src/AutoFactories/Diagnostics/DiagnosticIdentifier.cs
@@ -1,12 +1,29 @@
-using Vogen;
-
-namespace AutoFactories.Diagnostics
+namespace AutoFactories.Diagnostics
{
- [Instance("UnmarkedFactory", "AF1001")]
- [Instance("InconsistentFactoryAccessibility", "AF1002")]
- [Instance("ExposedAsIsNotDerivedType", "AF1003")]
- [Instance("UnresolvedParameterType", "AF1004")]
- [ValueObject(conversions: Conversions.None, toPrimitiveCasting: CastOperator.Implicit)]
- internal partial record DiagnosticIdentifier
- {}
-}
+
+ internal struct DiagnosticIdentifier
+ {
+ public static DiagnosticIdentifier UnmarkedFactory = new DiagnosticIdentifier("AF1001");
+ public static DiagnosticIdentifier InconsistentFactoryAccessibility = new DiagnosticIdentifier("AF1002");
+ public static DiagnosticIdentifier ExposedAsIsNotDerivedType = new DiagnosticIdentifier("AF1003");
+ public static DiagnosticIdentifier UnresolvedParameterType = new DiagnosticIdentifier("AF1004");
+
+ public readonly string Value;
+
+ private DiagnosticIdentifier(string value)
+ {
+ Value = value;
+ }
+
+ public static bool operator ==(DiagnosticIdentifier left, DiagnosticIdentifier right)
+ => left.Value == right.Value;
+
+ public static bool operator !=(DiagnosticIdentifier left, DiagnosticIdentifier right)
+ => left.Value != right.Value;
+
+ public static bool operator ==(DiagnosticIdentifier left, string right)
+ => left.Value == right;
+
+ public static bool operator !=(DiagnosticIdentifier left, string right) => left.Value != right;
+ }
+}
\ No newline at end of file
diff --git a/src/AutoFactories/ViewKey.cs b/src/AutoFactories/ViewKey.cs
index b21c748..4b75ad5 100644
--- a/src/AutoFactories/ViewKey.cs
+++ b/src/AutoFactories/ViewKey.cs
@@ -1,16 +1,25 @@
-using System;
-using System.IO;
-using Vogen;
+using System.IO;
namespace AutoFactories
{
- [Instance("Factory", "FactoryView")]
- [Instance("FactoryInterface", "FactoryInterfaceView")]
- [Instance("ClassAttribute", "ClassAttribute")]
- [Instance("ParameterAttribute", "ParameterAttribute")]
- [ValueObject(conversions: Conversions.None)]
public readonly partial struct ViewKey
{
+ public static ViewKey Factory = new ViewKey("FactoryView");
+ public static ViewKey FactoryInterface = new ViewKey("FactoryInterfaceView");
+ public static ViewKey ClassAttribute = new ViewKey("ClassAttribute");
+ public static ViewKey ParameterAttribute = new ViewKey("ParameterAttribute");
+
+
+ public readonly string Value;
+
+ private ViewKey(string value)
+ {
+ Value = value;
+ }
+
+ public static ViewKey From(string input)
+ => new ViewKey(NormalizeInput(input));
+
private static string NormalizeInput(string input)
=> Path.GetFileNameWithoutExtension(input);
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index a98b250..3425f23 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -24,18 +24,4 @@
-
-
-
-
- <_EmbeddedCodeAnalysisAssembly Include="@(EmbeddedResource)" Condition="$([System.String]::Copy('%(FileName)').StartsWith('Microsoft.CodeAnalysis'))" />
-
-
-
\ No newline at end of file