Skip to content

Commit

Permalink
Apply formatting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kzu committed Nov 24, 2024
1 parent d1ed4c5 commit f550d3a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/StructId.Analyzer/ConstructorGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public void Initialize(IncrementalGeneratorInitializationContext context)

void GenerateCode(SourceProductionContext context, INamedTypeSymbol symbol)
{
var ns = symbol.ContainingNamespace.Equals(symbol.ContainingModule.GlobalNamespace, SymbolEqualityComparer.Default)
? null
var ns = symbol.ContainingNamespace.Equals(symbol.ContainingModule.GlobalNamespace, SymbolEqualityComparer.Default)
? null
: symbol.ContainingNamespace.ToDisplayString();

// Generic IStructId<T> -> T, otherwise string
Expand Down
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/JsonConverterGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ namespace StructId;
[Generator(LanguageNames.CSharp)]
public class JsonConverterGenerator() : TemplateGenerator(
"System.IParsable`1",
ThisAssembly.Resources.Templates.JsonConverter.Text,
ThisAssembly.Resources.Templates.JsonConverter.Text,
ThisAssembly.Resources.Templates.JsonConverterT.Text);
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/NJsonConverterGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace StructId;
[Generator(LanguageNames.CSharp)]
public class NJsonConverterGenerator() : TemplateGenerator(
"Newtonsoft.Json.JsonConverter",
ThisAssembly.Resources.Templates.NJsonConverter.Text,
ThisAssembly.Resources.Templates.NJsonConverter.Text,
ThisAssembly.Resources.Templates.NJsonConverterT.Text,
TypeCheck.TypeExists);
2 changes: 1 addition & 1 deletion src/StructId.Analyzer/NewableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ namespace StructId;
public class NewableGenerator() : TemplateGenerator(
"System.Object",
ThisAssembly.Resources.Templates.Newable.Text,
ThisAssembly.Resources.Templates.NewableT.Text,
ThisAssembly.Resources.Templates.NewableT.Text,
TypeCheck.TypeExists);
5 changes: 2 additions & 3 deletions src/StructId.Analyzer/TemplateGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
Expand Down Expand Up @@ -35,7 +34,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
.Select((x, _) => (InterfaceType: x.GetTypeByMetadataName(valueType), StringType: x.GetTypeByMetadataName("System.String")));

var ids = context.CompilationProvider
.SelectMany((x, _) => x.Assembly.GetAllTypes().OfType<INamedTypeSymbol>())
.SelectMany((x, _) => x.Assembly.GetAllTypes().OfType<INamedTypeSymbol>())
.Where(x => x.IsStructId())
.Where(x => x.IsPartial());

Expand Down
12 changes: 2 additions & 10 deletions src/StructId.FunctionalTests/Functional.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;

namespace StructId.Functional;

Expand All @@ -26,7 +18,7 @@ public void Test()
var guid = Guid.NewGuid();
var id1 = new ProductId(guid);
var id2 = new ProductId(guid);

Assert.Equal(id1, id2);
Assert.True(id1 == id2);
}
Expand Down
6 changes: 2 additions & 4 deletions src/StructId.Tests/ParsableGeneratorTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Text;
using Microsoft.CodeAnalysis.CSharp.Testing;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.CodeAnalysis.Text;
using static StructId.RoslynTestingExtensions;

namespace StructId;

Expand All @@ -24,9 +22,9 @@ public async Task GenerateParseable()
public readonly partial record struct UserId(int Value) : IStructId<int>;
""",
},
GeneratedSources =
GeneratedSources =
{
(typeof(ParsableGenerator), "UserId.cs",
(typeof(ParsableGenerator), "UserId.cs",
ThisAssembly.Resources.StructId.Templates.ParsableT.Text.Replace("TStruct", "UserId").Replace("TValue", "int"),
Encoding.UTF8)
},
Expand Down

0 comments on commit f550d3a

Please sign in to comment.