-
-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathMockParameterModel.cs
More file actions
56 lines (50 loc) · 1.81 KB
/
Copy pathMockParameterModel.cs
File metadata and controls
56 lines (50 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
namespace TUnit.Mocks.SourceGenerator.Models;
internal sealed record MockParameterModel : IEquatable<MockParameterModel>
{
public string Name { get; init; } = "";
public string Type { get; init; } = "";
public string FullyQualifiedType { get; init; } = "";
public ParameterDirection Direction { get; init; } = ParameterDirection.In;
public bool HasDefaultValue { get; init; }
public string? DefaultValueExpression { get; init; }
public bool IsValueType { get; init; }
public bool IsRefStruct { get; init; }
/// <summary>
/// For ReadOnlySpan<T> or Span<T> parameters, the fully qualified element type (e.g. "byte").
/// Null for non-span parameters. Used to support out/ref span parameters via array conversion.
/// </summary>
public string? SpanElementType { get; init; }
public bool Equals(MockParameterModel? other)
{
if (other is null) return false;
return Name == other.Name
&& Type == other.Type
&& FullyQualifiedType == other.FullyQualifiedType
&& Direction == other.Direction
&& IsValueType == other.IsValueType
&& IsRefStruct == other.IsRefStruct
&& SpanElementType == other.SpanElementType;
}
public override int GetHashCode()
{
unchecked
{
int hash = 17;
hash = hash * 31 + Name.GetHashCode();
hash = hash * 31 + Type.GetHashCode();
hash = hash * 31 + (int)Direction;
hash = hash * 31 + IsValueType.GetHashCode();
hash = hash * 31 + IsRefStruct.GetHashCode();
hash = hash * 31 + (SpanElementType?.GetHashCode() ?? 0);
return hash;
}
}
}
internal enum ParameterDirection
{
In,
Out,
Ref,
In_Readonly // in keyword
}