From a61d9b6921c0637581f50e5945f4be759d9bab44 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 27 Jun 2019 15:58:43 -0700 Subject: [PATCH] Add some missing doc comments \n\nCommit migrated from https://github.com/dotnet/extensions/commit/238b272238ff4382df9a2fc5c7d92a0d68aafa97 --- .../Abstractions/src/LocalizedString.cs | 10 +++++++--- .../src/StringLocalizerExtensions.cs | 7 +++++-- .../Localization/src/LocalizationOptions.cs | 6 ++++++ .../Localization/src/ResourceNamesCache.cs | 11 +++++++++-- src/ObjectPool/src/DefaultObjectPool.cs | 13 +++++++++++++ src/ObjectPool/src/DefaultObjectPoolProvider.cs | 7 +++++++ src/ObjectPool/src/IPooledObjectPolicy.cs | 13 +++++++++++++ src/ObjectPool/src/ObjectPool.cs | 16 ++++++++++++++++ src/ObjectPool/src/ObjectPoolProvider.cs | 11 +++++++++++ 9 files changed, 87 insertions(+), 7 deletions(-) diff --git a/src/Localization/Abstractions/src/LocalizedString.cs b/src/Localization/Abstractions/src/LocalizedString.cs index 6556da40a0..7cac58d16a 100644 --- a/src/Localization/Abstractions/src/LocalizedString.cs +++ b/src/Localization/Abstractions/src/LocalizedString.cs @@ -1,5 +1,5 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -56,6 +56,10 @@ namespace Microsoft.Extensions.Localization SearchedLocation = searchedLocation; } + /// + /// Implicitly converts the to a . + /// + /// The string to be implicitly converted. public static implicit operator string(LocalizedString localizedString) { return localizedString?.Value; @@ -87,4 +91,4 @@ namespace Microsoft.Extensions.Localization /// The actual string. public override string ToString() => Value; } -} \ No newline at end of file +} diff --git a/src/Localization/Abstractions/src/StringLocalizerExtensions.cs b/src/Localization/Abstractions/src/StringLocalizerExtensions.cs index bde47f74f3..3a57475334 100644 --- a/src/Localization/Abstractions/src/StringLocalizerExtensions.cs +++ b/src/Localization/Abstractions/src/StringLocalizerExtensions.cs @@ -1,11 +1,14 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; namespace Microsoft.Extensions.Localization { + /// + /// Extension methods for operating on 's. + /// public static class StringLocalizerExtensions { /// diff --git a/src/Localization/Localization/src/LocalizationOptions.cs b/src/Localization/Localization/src/LocalizationOptions.cs index 1b7408fe67..1c0b82d210 100644 --- a/src/Localization/Localization/src/LocalizationOptions.cs +++ b/src/Localization/Localization/src/LocalizationOptions.cs @@ -8,6 +8,12 @@ namespace Microsoft.Extensions.Localization /// public class LocalizationOptions { + /// + /// Creates a new . + /// + public LocalizationOptions() + { } + /// /// The relative path under application root where resource files are located. /// diff --git a/src/Localization/Localization/src/ResourceNamesCache.cs b/src/Localization/Localization/src/ResourceNamesCache.cs index 86e94c102a..72b7986d9f 100644 --- a/src/Localization/Localization/src/ResourceNamesCache.cs +++ b/src/Localization/Localization/src/ResourceNamesCache.cs @@ -1,5 +1,5 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; @@ -14,6 +14,13 @@ namespace Microsoft.Extensions.Localization { private readonly ConcurrentDictionary> _cache = new ConcurrentDictionary>(); + /// + /// Creates a new + /// + public ResourceNamesCache() + { + } + /// public IList GetOrAdd(string name, Func> valueFactory) { diff --git a/src/ObjectPool/src/DefaultObjectPool.cs b/src/ObjectPool/src/DefaultObjectPool.cs index 070508a014..0ab6ed7608 100644 --- a/src/ObjectPool/src/DefaultObjectPool.cs +++ b/src/ObjectPool/src/DefaultObjectPool.cs @@ -8,6 +8,10 @@ using System.Threading; namespace Microsoft.Extensions.ObjectPool { + /// + /// Default implementation of . + /// + /// The type to pool objects for. public class DefaultObjectPool : ObjectPool where T : class { private protected readonly ObjectWrapper[] _items; @@ -18,11 +22,20 @@ namespace Microsoft.Extensions.ObjectPool // This class was introduced in 2.1 to avoid the interface call where possible private protected readonly PooledObjectPolicy _fastPolicy; + /// + /// Creates an instance of . + /// + /// The pooling policy to use. public DefaultObjectPool(IPooledObjectPolicy policy) : this(policy, Environment.ProcessorCount * 2) { } + /// + /// Creates an instance of . + /// + /// The pooling policy to use. + /// The maximum number of objects to retain in the pool. public DefaultObjectPool(IPooledObjectPolicy policy, int maximumRetained) { _policy = policy ?? throw new ArgumentNullException(nameof(policy)); diff --git a/src/ObjectPool/src/DefaultObjectPoolProvider.cs b/src/ObjectPool/src/DefaultObjectPoolProvider.cs index 2e7767ab35..f5085c26ef 100644 --- a/src/ObjectPool/src/DefaultObjectPoolProvider.cs +++ b/src/ObjectPool/src/DefaultObjectPoolProvider.cs @@ -5,10 +5,17 @@ using System; namespace Microsoft.Extensions.ObjectPool { + /// + /// A provider of 's. + /// public class DefaultObjectPoolProvider : ObjectPoolProvider { + /// + /// The maximum number of objects to retain in the pool. + /// public int MaximumRetained { get; set; } = Environment.ProcessorCount * 2; + /// public override ObjectPool Create(IPooledObjectPolicy policy) { if (policy == null) diff --git a/src/ObjectPool/src/IPooledObjectPolicy.cs b/src/ObjectPool/src/IPooledObjectPolicy.cs index 54611bad30..7bd9b9394a 100644 --- a/src/ObjectPool/src/IPooledObjectPolicy.cs +++ b/src/ObjectPool/src/IPooledObjectPolicy.cs @@ -3,10 +3,23 @@ namespace Microsoft.Extensions.ObjectPool { + /// + /// Represents a policy for managing pooled objects. + /// + /// The type of object which is being pooled. public interface IPooledObjectPolicy { + /// + /// Create a . + /// + /// The which was created. T Create(); + /// + /// Put an object in the pool. + /// + /// The object to put in the pool. + /// true if put in the pool. bool Return(T obj); } } diff --git a/src/ObjectPool/src/ObjectPool.cs b/src/ObjectPool/src/ObjectPool.cs index 691beae60c..f7065c2223 100644 --- a/src/ObjectPool/src/ObjectPool.cs +++ b/src/ObjectPool/src/ObjectPool.cs @@ -3,15 +3,31 @@ namespace Microsoft.Extensions.ObjectPool { + /// + /// A pool of objects. + /// + /// The type of objects to pool. public abstract class ObjectPool where T : class { + /// + /// Returns an object from the pool. + /// + /// An object from the pool. public abstract T Get(); + /// + /// Put an object in the pool. + /// + /// The object to add to the pool. public abstract void Return(T obj); } + /// + /// Methods for creating 's. + /// public static class ObjectPool { + /// public static ObjectPool Create(IPooledObjectPolicy policy = null) where T : class, new() { var provider = new DefaultObjectPoolProvider(); diff --git a/src/ObjectPool/src/ObjectPoolProvider.cs b/src/ObjectPool/src/ObjectPoolProvider.cs index 909795dd35..36db247bfe 100644 --- a/src/ObjectPool/src/ObjectPoolProvider.cs +++ b/src/ObjectPool/src/ObjectPoolProvider.cs @@ -3,13 +3,24 @@ namespace Microsoft.Extensions.ObjectPool { + /// + /// A provider of 's. + /// public abstract class ObjectPoolProvider { + /// + /// Creates an . + /// + /// The type to create a pool for. public ObjectPool Create() where T : class, new() { return Create(new DefaultPooledObjectPolicy()); } + /// + /// Creates an with the given . + /// + /// The type to create a pool for. public abstract ObjectPool Create(IPooledObjectPolicy policy) where T : class; } }