Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Require CookieBuilder.Name to be not null or empty #883

Merged
merged 1 commit into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Microsoft.AspNetCore.Http.Abstractions/CookieBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Microsoft.AspNetCore.Http.Abstractions;

namespace Microsoft.AspNetCore.Http
{
Expand All @@ -10,10 +11,18 @@ namespace Microsoft.AspNetCore.Http
/// </summary>
public class CookieBuilder
{
private string _name;

/// <summary>
/// The name of the cookie.
/// </summary>
public virtual string Name { get; set; }
public virtual string Name
{
get => _name;
set => _name = !string.IsNullOrEmpty(value)
? value
: throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(value));
}

/// <summary>
/// The cookie path.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Microsoft.AspNetCore.Http.Abstractions/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,7 @@
<data name="Exception_UseMiddlewareExplicitArgumentsNotSupported" xml:space="preserve">
<value>Types that implement '{0}' do not support explicit arguments.</value>
</data>
<data name="ArgumentCannotBeNullOrEmpty" xml:space="preserve">
<value>Argument cannot be null or empty.</value>
</data>
</root>