Skip to content

Commit 390ff96

Browse files
authored
Update xml comments for data loaders, ValueConverter, misc (graphql-dotnet#2000)
1 parent ffa3de7 commit 390ff96

File tree

8 files changed

+68
-0
lines changed

8 files changed

+68
-0
lines changed

src/GraphQL/Conversion/ValueConverter.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,21 @@ static ValueConverter()
132132
Register<char, int>(value => Convert.ToInt32(value));
133133
}
134134

135+
/// <summary>
136+
/// <para>Returns an object of the specified type and whose value is equivalent to the specified object.</para>
137+
/// <para>Throws a <see cref="InvalidOperationException"/> if there is no conversion registered; conversion functions may throw other exceptions</para>
138+
/// </summary>
135139
public static T ConvertTo<T>(object value)
136140
{
137141
object v = ConvertTo(value, typeof(T));
138142

139143
return v == null ? default : (T)v;
140144
}
141145

146+
/// <summary>
147+
/// <para>Returns an object of the specified type and whose value is equivalent to the specified object.</para>
148+
/// <para>Throws a <see cref="InvalidOperationException"/> if there is no conversion registered; conversion functions may throw other exceptions</para>
149+
/// </summary>
142150
public static object ConvertTo(object value, Type targetType)
143151
{
144152
if (!TryConvertTo(value, targetType, out object result))
@@ -147,6 +155,10 @@ public static object ConvertTo(object value, Type targetType)
147155
return result;
148156
}
149157

158+
/// <summary>
159+
/// <para>If a conversion delegate was registered, converts an object to the specified type and returns <c>true</c>; returns <c>false</c> if no conversion delegate is registered.</para>
160+
/// <para>Conversion delegates may throw exceptions if the conversion was unsuccessful</para>
161+
/// </summary>
150162
internal static bool TryConvertTo(object value, Type targetType, out object result, Type sourceType = null)
151163
{
152164
if (value == null || targetType.IsInstanceOfType(value))

src/GraphQL/DataLoader/DataLoaderContextAccessor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace GraphQL.DataLoader
44
{
5+
/// <inheritdoc cref="IDataLoaderContextAccessor"/>
56
public class DataLoaderContextAccessor : IDataLoaderContextAccessor
67
{
78
private static readonly AsyncLocal<DataLoaderContext> _current = new AsyncLocal<DataLoaderContext>();
89

10+
/// <inheritdoc/>
911
public DataLoaderContext Context
1012
{
1113
get => _current.Value;

src/GraphQL/DataLoader/DataLoaderContextExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace GraphQL.DataLoader
88
{
9+
/// <summary>
10+
/// Provides extension methods for retrieving <see cref="IDataLoader"/> implementations via a <see cref="DataLoaderContext"/>
11+
/// </summary>
912
public static class DataLoaderContextExtensions
1013
{
1114
public static Func<CancellationToken, TResult> WrapNonCancellableFunc<TResult>(Func<TResult> func) => cancellationToken => func();

src/GraphQL/DataLoader/DataLoaderDocumentListener.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@ public class DataLoaderDocumentListener : IDocumentExecutionListener
1212
{
1313
private readonly IDataLoaderContextAccessor _accessor;
1414

15+
/// <summary>
16+
/// Constructs a <see cref="DataLoaderDocumentListener"/> with the specified <see cref="IDataLoaderContextAccessor"/>
17+
/// </summary>
1518
public DataLoaderDocumentListener(IDataLoaderContextAccessor accessor)
1619
{
1720
_accessor = accessor;
1821
}
1922

23+
/// <inheritdoc/>
2024
public Task AfterValidationAsync(IExecutionContext context, IValidationResult validationResult)
2125
=> Task.CompletedTask;
2226

27+
/// <inheritdoc/>
2328
public Task BeforeExecutionAsync(IExecutionContext context)
2429
{
2530
if (_accessor.Context == null)
@@ -28,16 +33,19 @@ public Task BeforeExecutionAsync(IExecutionContext context)
2833
return Task.CompletedTask;
2934
}
3035

36+
/// <inheritdoc/>
3137
public Task BeforeExecutionAwaitedAsync(IExecutionContext context)
3238
=> Task.CompletedTask;
3339

40+
/// <inheritdoc/>
3441
public Task AfterExecutionAsync(IExecutionContext context)
3542
{
3643
_accessor.Context = null;
3744

3845
return Task.CompletedTask;
3946
}
4047

48+
/// <inheritdoc/>
4149
public Task BeforeExecutionStepAwaitedAsync(IExecutionContext context)
4250
=> Task.CompletedTask;
4351
}

src/GraphQL/DataLoader/DataLoaderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace GraphQL.DataLoader
1010
{
11+
/// <summary>
12+
/// Provides extension methods useful for data loaders
13+
/// </summary>
1114
public static class DataLoaderExtensions
1215
{
1316
/// <summary>

src/GraphQL/Execution/ErrorInfoProvider.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,32 @@
77

88
namespace GraphQL.Execution
99
{
10+
/// <inheritdoc cref="IErrorInfoProvider"/>
1011
public class ErrorInfoProvider : IErrorInfoProvider
1112
{
1213
private static readonly ConcurrentDictionary<Type, string> _exceptionErrorCodes = new ConcurrentDictionary<Type, string>();
1314

1415
private readonly ErrorInfoProviderOptions _options;
1516

17+
/// <summary>
18+
/// Initializes an <see cref="ErrorInfoProvider"/> with a default set of <see cref="ErrorInfoProviderOptions"/>.
19+
/// </summary>
1620
public ErrorInfoProvider()
1721
: this(new ErrorInfoProviderOptions())
1822
{
1923
}
2024

25+
/// <summary>
26+
/// Initializes an <see cref="ErrorInfoProvider"/> with a specified set of <see cref="ErrorInfoProviderOptions"/>.
27+
/// </summary>
2128
public ErrorInfoProvider(ErrorInfoProviderOptions options)
2229
{
2330
_options = options ?? throw new ArgumentNullException(nameof(options));
2431
}
2532

33+
/// <summary>
34+
/// Initializes an <see cref="ErrorInfoProvider"/> with a set of <see cref="ErrorInfoProviderOptions"/> filled out by the specified delegate.
35+
/// </summary>
2636
public ErrorInfoProvider(Action<ErrorInfoProviderOptions> optionsBuilder)
2737
{
2838
if (optionsBuilder == null)
@@ -31,6 +41,7 @@ public ErrorInfoProvider(Action<ErrorInfoProviderOptions> optionsBuilder)
3141
optionsBuilder(_options);
3242
}
3343

44+
/// <inheritdoc/>
3445
public virtual ErrorInfo GetInfo(ExecutionError executionError)
3546
{
3647
if (executionError == null)
@@ -68,6 +79,13 @@ public virtual ErrorInfo GetInfo(ExecutionError executionError)
6879
};
6980
}
7081

82+
/// <summary>
83+
/// <para>Returns a list of error codes derived from a specified <see cref="ExecutionError"/> instance.</para>
84+
/// <para>
85+
/// By default, this returns the <see cref="ExecutionError.Code"/> value if set, along with
86+
/// codes generated from the type of the <see cref="Exception.InnerException"/> and all their inner exceptions.
87+
/// </para>
88+
/// </summary>
7189
protected virtual IEnumerable<string> GetCodesForError(ExecutionError executionError)
7290
{
7391
// Code could be set explicitly, and not through the constructor with the exception

src/GraphQL/Execution/ExecutionError.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,23 +96,44 @@ private void SetData(IDictionary dict)
9696
}
9797
}
9898

99+
/// <summary>
100+
/// Represents a location within a document where a parsing or execution error occurred.
101+
/// </summary>
99102
public struct ErrorLocation : IEquatable<ErrorLocation>
100103
{
104+
/// <summary>
105+
/// The line number of the document where the error occurred, where 1 is the first line.
106+
/// </summary>
101107
public int Line { get; set; }
102108

109+
/// <summary>
110+
/// The column number of the document where the error occurred, where 1 is the first column.
111+
/// </summary>
103112
public int Column { get; set; }
104113

114+
/// <inheritdoc/>
105115
public bool Equals(ErrorLocation other) => Line == other.Line && Column == other.Column;
106116

117+
/// <inheritdoc/>
107118
public override bool Equals(object obj) => obj is Location loc && Equals(loc);
108119

120+
/// <inheritdoc/>
109121
public override int GetHashCode() => (Line, Column).GetHashCode();
110122

123+
/// <summary>
124+
/// Indicates whether two <see cref="ErrorLocation"/> instances are the same.
125+
/// </summary>
111126
public static bool operator ==(ErrorLocation left, ErrorLocation right) => left.Equals(right);
112127

128+
/// <summary>
129+
/// Indicates whether two <see cref="ErrorLocation"/> instances are not the same.
130+
/// </summary>
113131
public static bool operator !=(ErrorLocation left, ErrorLocation right) => !(left == right);
114132
}
115133

134+
/// <summary>
135+
/// Provides extension methods for <see cref="ExecutionError"/> instances.
136+
/// </summary>
116137
public static class ExecutionErrorExtensions
117138
{
118139
/// <summary>

src/GraphQL/Execution/ExecutionOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class ExecutionOptions : IProvideUserContext
4343
/// <summary>Validation rules to be used by the <see cref="IDocumentValidator"/>; defaults to standard list of of validation rules - see <see cref="DocumentValidator.CoreRules"/></summary>
4444
public IEnumerable<IValidationRule> ValidationRules { get; set; }
4545

46+
/// <inheritdoc/>
4647
public IDictionary<string, object> UserContext { get; set; } = new Dictionary<string, object>();
4748

4849
/// <summary>

0 commit comments

Comments
 (0)