Skip to content

Commit 150d705

Browse files
committed
Remove dead code
1 parent 212b657 commit 150d705

File tree

10 files changed

+0
-362
lines changed

10 files changed

+0
-362
lines changed

src/Rocks.Analysis.Tests/Extensions/AttributeDataExtensionsTests.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,6 @@ public MyTestAttribute(string a, double b, int c, uint d, Type e, int[] f, MyVal
5858

5959
public static class AttributeDataExtensionsTests
6060
{
61-
[Test]
62-
public static void GetNamespaces()
63-
{
64-
var (attributes, compilation) = AttributeDataExtensionsTests.GetAttributes(
65-
$$"""
66-
using {{typeof(TypeOfThis).Namespace}};
67-
using {{typeof(MethodAttribute).Namespace}};
68-
69-
public interface IA
70-
{
71-
[Method(typeof(TypeOfThis))]
72-
void Foo();
73-
}
74-
""");
75-
76-
var namespaces = attributes[0].GetNamespaces();
77-
78-
Assert.Multiple(() =>
79-
{
80-
Assert.That(namespaces, Has.Count.EqualTo(2));
81-
Assert.That(namespaces.Any(_ => _.Name == typeof(TypeOfThis).Namespace), Is.True);
82-
Assert.That(namespaces.Any(_ => _.Name == typeof(MethodAttribute).Namespace), Is.True);
83-
});
84-
}
85-
8661
[Test]
8762
public static void GetDescriptionWithSpecialCharactersInString()
8863
{

src/Rocks.Analysis.Tests/Extensions/IEventSymbolGetNamespacesExtensionsTests.cs

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/Rocks.Analysis.Tests/Extensions/IMethodSymbolExtensionsGetNamespacesTests.cs

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/Rocks.Analysis.Tests/Extensions/ObjectExtensionsTests.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,6 @@ public static void GetDefaultValue(string code, string expectedResult)
7474
Assert.That(parameter.ExplicitDefaultValue.GetDefaultValue(parameter.Type, compilation), Is.EqualTo(expectedResult));
7575
}
7676

77-
[Test]
78-
public static void FormatValue() =>
79-
Assert.That(33.FormatValue(), Is.EqualTo("33"));
80-
81-
[Test]
82-
public static void FormatEnumValue() =>
83-
Assert.That(ObjectExtensionValues.Some.FormatValue(), Is.EqualTo("Rocks.Analysis.Tests.Extensions.ObjectExtensionValues.Some"));
84-
85-
[Test]
86-
public static void FormatEnumValueWhenValueIsIncorrect() =>
87-
Assert.That(((ObjectExtensionValues)22).FormatValue(), Is.EqualTo("(Rocks.Analysis.Tests.Extensions.ObjectExtensionValues)22"));
88-
89-
[Test]
90-
public static void FormatNullValue() =>
91-
Assert.That((null as string).FormatValue(), Is.EqualTo("null"));
92-
93-
[Test]
94-
public static void FormatCollectionValue() =>
95-
Assert.That((new int[] { 1, 2, 3 }).FormatValue(), Is.EqualTo("System.Int32[], Count = 3"));
96-
9777
private static (IParameterSymbol, Compilation) GetParameterSymbol(string source)
9878
{
9979
var syntaxTree = CSharpSyntaxTree.ParseText(source);

src/Rocks.Analysis/Extensions/AttributeDataExtensions.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,6 @@ namespace Rocks.Analysis.Extensions;
88

99
internal static class AttributeDataExtensions
1010
{
11-
internal static ImmutableHashSet<INamespaceSymbol> GetNamespaces(this AttributeData self)
12-
{
13-
static IEnumerable<INamespaceSymbol> GetNamespacesForValue(TypedConstant value)
14-
{
15-
if (value.Kind == TypedConstantKind.Primitive || value.Kind == TypedConstantKind.Enum)
16-
{
17-
yield return value.Type!.ContainingNamespace;
18-
}
19-
else if (value.Kind == TypedConstantKind.Type)
20-
{
21-
yield return ((INamedTypeSymbol)value.Value!).ContainingNamespace;
22-
}
23-
else if (value.Kind == TypedConstantKind.Array)
24-
{
25-
yield return value.Type!.ContainingNamespace;
26-
27-
foreach (var arrayValue in value.Values)
28-
{
29-
foreach (var arrayValueNamespace in GetNamespacesForValue(arrayValue))
30-
{
31-
yield return arrayValueNamespace;
32-
}
33-
}
34-
}
35-
}
36-
37-
return
38-
[
39-
self.AttributeClass!.ContainingNamespace,
40-
.. self.ConstructorArguments.SelectMany(_ => GetNamespacesForValue(_)),
41-
.. self.NamedArguments.SelectMany(_ => GetNamespacesForValue(_.Value)),
42-
];
43-
}
44-
4511
internal static string GetDescription(this AttributeData self, Compilation compilation)
4612
{
4713
static string GetTypedConstantValue(TypedConstant value, Compilation compilation) =>

src/Rocks.Analysis/Extensions/IEventSymbolExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,4 @@ internal static bool CanBeSeenByContainingAssembly(this IEventSymbol self, IAsse
1414
Compilation compilation) =>
1515
((ISymbol)self).CanBeSeenByContainingAssembly(assembly, compilation) &&
1616
self.Type.CanBeSeenByContainingAssembly(assembly, compilation);
17-
18-
internal static ImmutableHashSet<INamespaceSymbol> GetNamespaces(this IEventSymbol self) =>
19-
[.. self.Type.GetNamespaces(), .. self.GetAttributes().SelectMany(_ => _.GetNamespaces())];
2017
}

src/Rocks.Analysis/Extensions/IMethodSymbolExtensions.cs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -108,35 +108,6 @@ internal static EquatableArray<Constraints> GetConstraints(this IMethodSymbol se
108108
return [.. constraints];
109109
}
110110

111-
internal static ImmutableHashSet<INamespaceSymbol> GetNamespaces(this IMethodSymbol self)
112-
{
113-
static IEnumerable<INamespaceSymbol> GetParameterNamespaces(IParameterSymbol parameter)
114-
{
115-
foreach (var parameterTypeNamespace in parameter.Type.GetNamespaces())
116-
{
117-
yield return parameterTypeNamespace;
118-
}
119-
120-
foreach (var attributeNamespace in parameter.GetAttributes().SelectMany(_ => _.GetNamespaces()))
121-
{
122-
yield return attributeNamespace;
123-
}
124-
}
125-
126-
var namespaces = new HashSet<INamespaceSymbol>();
127-
128-
if (!self.ReturnsVoid)
129-
{
130-
namespaces.AddRange(self.ReturnType.GetNamespaces());
131-
namespaces.AddRange(self.GetReturnTypeAttributes().SelectMany(_ => _.GetNamespaces()));
132-
}
133-
134-
namespaces.AddRange(self.GetAttributes().SelectMany(_ => _.GetNamespaces()));
135-
namespaces.AddRange(self.Parameters.SelectMany(_ => GetParameterNamespaces(_)));
136-
137-
return [.. namespaces];
138-
}
139-
140111
internal static MethodMatch Match(this IMethodSymbol self, IMethodSymbol other, Compilation compilation)
141112
{
142113
if (self.Name != other.Name)

src/Rocks.Analysis/Extensions/IPropertySymbolExtensions.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,6 @@ internal static ImmutableArray<AttributeData> GetAllAttributes(this IPropertySym
3232
return [.. attributes];
3333
}
3434

35-
internal static ImmutableHashSet<INamespaceSymbol> GetNamespaces(this IPropertySymbol self)
36-
{
37-
static IEnumerable<INamespaceSymbol> GetParameterNamespaces(IParameterSymbol parameter)
38-
{
39-
foreach (var parameterTypeNamespaces in parameter.Type.GetNamespaces())
40-
{
41-
yield return parameterTypeNamespaces;
42-
}
43-
44-
foreach (var attributeNamespace in parameter.GetAttributes().SelectMany(_ => _.GetNamespaces()))
45-
{
46-
yield return attributeNamespace;
47-
}
48-
}
49-
50-
var namespaces = new HashSet<INamespaceSymbol>();
51-
52-
namespaces.AddRange(self.GetAllAttributes().SelectMany(_ => _.GetNamespaces()));
53-
namespaces.AddRange(self.Type.GetNamespaces());
54-
55-
if (self.IsIndexer)
56-
{
57-
namespaces.AddRange(self.Parameters.SelectMany(_ => GetParameterNamespaces(_)));
58-
}
59-
60-
return [.. namespaces];
61-
}
62-
6335
internal static bool IsUnsafe(this IPropertySymbol self) =>
6436
self.IsIndexer ? (self.Parameters.Any(_ => _.Type.IsPointer()) || self.Type.IsPointer()) : self.Type.IsPointer();
6537

src/Rocks.Analysis/Extensions/ObjectExtensions.cs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,6 @@ namespace Rocks.Analysis.Extensions;
88
/// </summary>
99
public static class ObjectExtensions
1010
{
11-
// TODO: If I could project this code like I do for RefStructArgument,
12-
// I might be able to do a FormatValue<T>(this T self) where T : allows ref struct.
13-
14-
/// <summary>
15-
/// This gets a stringified version of a value
16-
/// that will be put into the call site of an emitted method.
17-
/// </summary>
18-
public static string FormatValue(this object? self)
19-
{
20-
if (self is Enum)
21-
{
22-
var selfType = self.GetType();
23-
var selfName = Enum.GetName(selfType, self);
24-
var selfValue = selfName is not null ?
25-
$"{selfType.FullName}.{selfName}" :
26-
$"({selfType.FullName}){self}";
27-
28-
return selfValue;
29-
}
30-
else if (self is ICollection c)
31-
{
32-
return $"{c}, Count = {c.Count}";
33-
}
34-
else if (self is null)
35-
{
36-
return "null";
37-
}
38-
else
39-
{
40-
return self.ToString();
41-
}
42-
}
43-
4411
/// <summary>
4512
/// This should only be used to get a stringified version of a default value
4613
/// that will be put into the call site of an emitted method.

0 commit comments

Comments
 (0)