Removing Microsoft.Framework.Primitives from HttpAbstractions
This commit is contained in:
parent
ceded805f3
commit
7816c0183e
|
|
@ -47,10 +47,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{982F
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleApp", "samples\SampleApp\SampleApp.xproj", "{1D0764B4-1DEB-4232-A714-D4B7E846918A}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SampleApp", "samples\SampleApp\SampleApp.xproj", "{1D0764B4-1DEB-4232-A714-D4B7E846918A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Primitives", "src\Microsoft.Framework.Primitives\Microsoft.Framework.Primitives.xproj", "{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Primitives.Tests", "test\Microsoft.Framework.Primitives.Tests\Microsoft.Framework.Primitives.Tests.xproj", "{61F72E92-B3AE-4A10-B838-44F80AED40AE}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Html.Abstractions.Test", "test\Microsoft.AspNet.Html.Abstractions.Test\Microsoft.AspNet.Html.Abstractions.Test.xproj", "{2D187B88-94BD-4A39-AC97-F8F8B9363301}"
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Html.Abstractions.Test", "test\Microsoft.AspNet.Html.Abstractions.Test\Microsoft.AspNet.Html.Abstractions.Test.xproj", "{2D187B88-94BD-4A39-AC97-F8F8B9363301}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|
@ -267,30 +263,6 @@ Global
|
||||||
{1D0764B4-1DEB-4232-A714-D4B7E846918A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
{1D0764B4-1DEB-4232-A714-D4B7E846918A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{1D0764B4-1DEB-4232-A714-D4B7E846918A}.Release|x86.ActiveCfg = Release|Any CPU
|
{1D0764B4-1DEB-4232-A714-D4B7E846918A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{1D0764B4-1DEB-4232-A714-D4B7E846918A}.Release|x86.Build.0 = Release|Any CPU
|
{1D0764B4-1DEB-4232-A714-D4B7E846918A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Debug|x86.Build.0 = Debug|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Release|x86.ActiveCfg = Release|Any CPU
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE}.Release|x86.Build.0 = Release|Any CPU
|
|
||||||
{2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
{2D187B88-94BD-4A39-AC97-F8F8B9363301}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
|
@ -327,8 +299,6 @@ Global
|
||||||
{BE9112CB-D87D-4080-9CC3-24492D49CBE6} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
|
{BE9112CB-D87D-4080-9CC3-24492D49CBE6} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
|
||||||
{68A28E4A-3ADE-4187-9625-4FF185887CB3} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
|
{68A28E4A-3ADE-4187-9625-4FF185887CB3} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
|
||||||
{1D0764B4-1DEB-4232-A714-D4B7E846918A} = {982F09D8-621E-4872-BA7B-BBDEA47D1EFD}
|
{1D0764B4-1DEB-4232-A714-D4B7E846918A} = {982F09D8-621E-4872-BA7B-BBDEA47D1EFD}
|
||||||
{E5FACCD4-6327-43AA-80A9-AE6F4A3BFE6A} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
|
|
||||||
{61F72E92-B3AE-4A10-B838-44F80AED40AE} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
|
|
||||||
{2D187B88-94BD-4A39-AC97-F8F8B9363301} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
|
{2D187B88-94BD-4A39-AC97-F8F8B9363301} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>e5faccd4-6327-43aa-80a9-ae6f4a3bfe6a</ProjectGuid>
|
|
||||||
<RootNamespace>Microsoft.AspNet.Primitives</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
// 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.Reflection;
|
|
||||||
using System.Resources;
|
|
||||||
|
|
||||||
[assembly: AssemblyMetadata("Serviceable", "True")]
|
|
||||||
[assembly: NeutralResourcesLanguage("en-us")]
|
|
||||||
|
|
@ -1,312 +0,0 @@
|
||||||
// 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;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Microsoft.Framework.Primitives
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Represents zero/null, one, or many strings in an efficient way.
|
|
||||||
/// </summary>
|
|
||||||
public struct StringValues : IList<string>, IReadOnlyList<string>
|
|
||||||
{
|
|
||||||
private static readonly string[] EmptyArray = new string[0];
|
|
||||||
public static readonly StringValues Empty = new StringValues(EmptyArray);
|
|
||||||
|
|
||||||
private readonly string _value;
|
|
||||||
private readonly string[] _values;
|
|
||||||
|
|
||||||
public StringValues(string value)
|
|
||||||
{
|
|
||||||
_value = value;
|
|
||||||
_values = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringValues(string[] values)
|
|
||||||
{
|
|
||||||
_value = null;
|
|
||||||
_values = values;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static implicit operator StringValues(string value)
|
|
||||||
{
|
|
||||||
return new StringValues(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static implicit operator StringValues(string[] values)
|
|
||||||
{
|
|
||||||
return new StringValues(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static implicit operator string (StringValues values)
|
|
||||||
{
|
|
||||||
return values.GetStringValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static implicit operator string[] (StringValues value)
|
|
||||||
{
|
|
||||||
return value.GetArrayValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Count => _values?.Length ?? (_value != null ? 1 : 0);
|
|
||||||
|
|
||||||
bool ICollection<string>.IsReadOnly
|
|
||||||
{
|
|
||||||
get { return true; }
|
|
||||||
}
|
|
||||||
|
|
||||||
string IList<string>.this[int index]
|
|
||||||
{
|
|
||||||
get { return this[index]; }
|
|
||||||
set { throw new NotSupportedException(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string this[int index]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_values != null)
|
|
||||||
{
|
|
||||||
return _values[index]; // may throw
|
|
||||||
}
|
|
||||||
if (index == 0 && _value != null)
|
|
||||||
{
|
|
||||||
return _value;
|
|
||||||
}
|
|
||||||
return EmptyArray[0]; // throws
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return GetStringValue() ?? string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GetStringValue()
|
|
||||||
{
|
|
||||||
if (_values == null)
|
|
||||||
{
|
|
||||||
return _value;
|
|
||||||
}
|
|
||||||
switch (_values.Length)
|
|
||||||
{
|
|
||||||
case 0: return null;
|
|
||||||
case 1: return _values[0];
|
|
||||||
default: return string.Join(",", _values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string[] ToArray()
|
|
||||||
{
|
|
||||||
return GetArrayValue() ?? EmptyArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string[] GetArrayValue()
|
|
||||||
{
|
|
||||||
if (_value != null)
|
|
||||||
{
|
|
||||||
return new[] { _value };
|
|
||||||
}
|
|
||||||
return _values;
|
|
||||||
}
|
|
||||||
|
|
||||||
int IList<string>.IndexOf(string item)
|
|
||||||
{
|
|
||||||
return IndexOf(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int IndexOf(string item)
|
|
||||||
{
|
|
||||||
if (_values != null)
|
|
||||||
{
|
|
||||||
var values = _values;
|
|
||||||
for (int i = 0; i < values.Length; i++)
|
|
||||||
{
|
|
||||||
if (string.Equals(values[i], item, StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_value != null)
|
|
||||||
{
|
|
||||||
return string.Equals(_value, item, StringComparison.Ordinal) ? 0 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ICollection<string>.Contains(string item)
|
|
||||||
{
|
|
||||||
return IndexOf(item) >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICollection<string>.CopyTo(string[] array, int arrayIndex)
|
|
||||||
{
|
|
||||||
CopyTo(array, arrayIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CopyTo(string[] array, int arrayIndex)
|
|
||||||
{
|
|
||||||
if (_values != null)
|
|
||||||
{
|
|
||||||
Array.Copy(_values, 0, array, arrayIndex, _values.Length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_value != null)
|
|
||||||
{
|
|
||||||
if (array == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(array));
|
|
||||||
}
|
|
||||||
if (arrayIndex < 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex));
|
|
||||||
}
|
|
||||||
if (array.Length - arrayIndex < 1)
|
|
||||||
{
|
|
||||||
throw new ArgumentException(
|
|
||||||
$"'{nameof(array)}' is not long enough to copy all the items in the collection. Check '{nameof(arrayIndex)}' and '{nameof(array)}' length.");
|
|
||||||
}
|
|
||||||
|
|
||||||
array[arrayIndex] = _value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICollection<string>.Add(string item)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
void IList<string>.Insert(int index, string item)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ICollection<string>.Remove(string item)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
void IList<string>.RemoveAt(int index)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICollection<string>.Clear()
|
|
||||||
{
|
|
||||||
throw new NotSupportedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Enumerator GetEnumerator()
|
|
||||||
{
|
|
||||||
return new Enumerator(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator<string> IEnumerable<string>.GetEnumerator()
|
|
||||||
{
|
|
||||||
return GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator()
|
|
||||||
{
|
|
||||||
return GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsNullOrEmpty(StringValues value)
|
|
||||||
{
|
|
||||||
if (value._values == null)
|
|
||||||
{
|
|
||||||
return string.IsNullOrEmpty(value._value);
|
|
||||||
}
|
|
||||||
switch (value._values.Length)
|
|
||||||
{
|
|
||||||
case 0: return true;
|
|
||||||
case 1: return string.IsNullOrEmpty(value._values[0]);
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StringValues Concat(StringValues values1, StringValues values2)
|
|
||||||
{
|
|
||||||
var count1 = values1.Count;
|
|
||||||
var count2 = values2.Count;
|
|
||||||
|
|
||||||
if (count1 == 0)
|
|
||||||
{
|
|
||||||
return values2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count2 == 0)
|
|
||||||
{
|
|
||||||
return values1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var combined = new string[count1 + count2];
|
|
||||||
values1.CopyTo(combined, 0);
|
|
||||||
values2.CopyTo(combined, count1);
|
|
||||||
return new StringValues(combined);
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct Enumerator : IEnumerator<string>
|
|
||||||
{
|
|
||||||
private readonly StringValues _values;
|
|
||||||
private string _current;
|
|
||||||
private int _index;
|
|
||||||
|
|
||||||
public Enumerator(StringValues values)
|
|
||||||
{
|
|
||||||
_values = values;
|
|
||||||
_current = null;
|
|
||||||
_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
var values = _values._values;
|
|
||||||
if (values != null)
|
|
||||||
{
|
|
||||||
if (_index < values.Length)
|
|
||||||
{
|
|
||||||
_current = values[_index];
|
|
||||||
_index++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
_current = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var value = _values._value;
|
|
||||||
if (value != null && _index == 0)
|
|
||||||
{
|
|
||||||
_current = value;
|
|
||||||
_index = -1; // sentinel value
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
_current = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Current => _current;
|
|
||||||
|
|
||||||
object IEnumerator.Current => _current;
|
|
||||||
|
|
||||||
void IEnumerator.Reset()
|
|
||||||
{
|
|
||||||
_current = null;
|
|
||||||
_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IDisposable.Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"version": "1.0.0-*",
|
|
||||||
"description": "Contains primitive types such as StringValues.",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git://github.com/aspnet/httpabstractions"
|
|
||||||
},
|
|
||||||
"compilationOptions": {
|
|
||||||
"warningsAsErrors": true
|
|
||||||
},
|
|
||||||
"frameworks": {
|
|
||||||
"net451": { },
|
|
||||||
"dnx451": { },
|
|
||||||
"dnxcore50": {
|
|
||||||
"dependencies": {
|
|
||||||
"System.Collections": "4.0.11-beta-*",
|
|
||||||
"System.Resources.ResourceManager": "4.0.1-beta-"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>61f72e92-b3ae-4a10-b838-44f80aed40ae</ProjectGuid>
|
|
||||||
<RootNamespace>Microsoft.AspNet.Primitives.Tests</RootNamespace>
|
|
||||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
|
||||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
|
||||||
</Project>
|
|
||||||
|
|
@ -1,306 +0,0 @@
|
||||||
// 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;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace Microsoft.Framework.Primitives
|
|
||||||
{
|
|
||||||
public class StringValuesTests
|
|
||||||
{
|
|
||||||
public static TheoryData<StringValues> DefaultOrNullStringValues
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new TheoryData<StringValues>
|
|
||||||
{
|
|
||||||
new StringValues(),
|
|
||||||
new StringValues((string)null),
|
|
||||||
new StringValues((string[])null),
|
|
||||||
(string)null,
|
|
||||||
(string[])null
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TheoryData<StringValues> EmptyStringValues
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new TheoryData<StringValues>
|
|
||||||
{
|
|
||||||
StringValues.Empty,
|
|
||||||
new StringValues(new string[0]),
|
|
||||||
new string[0]
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TheoryData<StringValues> FilledStringValues
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new TheoryData<StringValues>
|
|
||||||
{
|
|
||||||
new StringValues("abc"),
|
|
||||||
new StringValues(new[] { "abc" }),
|
|
||||||
new StringValues(new[] { "abc", "bcd" }),
|
|
||||||
new StringValues(new[] { "abc", "bcd", "foo" }),
|
|
||||||
"abc",
|
|
||||||
new[] { "abc" },
|
|
||||||
new[] { "abc", "bcd" },
|
|
||||||
new[] { "abc", "bcd", "foo" }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TheoryData<StringValues, string[]> FilledStringValuesWithExpected
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return new TheoryData<StringValues, string[]>
|
|
||||||
{
|
|
||||||
{ new StringValues("abc"), new[] { "abc" } },
|
|
||||||
{ new StringValues(new[] { "abc" }), new[] { "abc" } },
|
|
||||||
{ new StringValues(new[] { "abc", "bcd" }), new[] { "abc", "bcd" } },
|
|
||||||
{ new StringValues(new[] { "abc", "bcd", "foo" }), new[] { "abc", "bcd", "foo" } },
|
|
||||||
{ "abc", new[] { "abc" } },
|
|
||||||
{ new[] { "abc" }, new[] { "abc" } },
|
|
||||||
{ new[] { "abc", "bcd" }, new[] { "abc", "bcd" } },
|
|
||||||
{ new[] { "abc", "bcd", "foo" }, new[] { "abc", "bcd", "foo" } }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(DefaultOrNullStringValues))]
|
|
||||||
[MemberData(nameof(EmptyStringValues))]
|
|
||||||
[MemberData(nameof(FilledStringValues))]
|
|
||||||
public void IsReadOnly_True(StringValues stringValues)
|
|
||||||
{
|
|
||||||
Assert.True(((IList<string>)stringValues).IsReadOnly);
|
|
||||||
Assert.Throws<NotSupportedException>(() => ((IList<string>)stringValues)[0] = string.Empty);
|
|
||||||
Assert.Throws<NotSupportedException>(() => ((ICollection<string>)stringValues).Add(string.Empty));
|
|
||||||
Assert.Throws<NotSupportedException>(() => ((IList<string>)stringValues).Insert(0, string.Empty));
|
|
||||||
Assert.Throws<NotSupportedException>(() => ((ICollection<string>)stringValues).Remove(string.Empty));
|
|
||||||
Assert.Throws<NotSupportedException>(() => ((IList<string>)stringValues).RemoveAt(0));
|
|
||||||
Assert.Throws<NotSupportedException>(() => ((ICollection<string>)stringValues).Clear());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(DefaultOrNullStringValues))]
|
|
||||||
public void DefaultOrNull_ExpectedValues(StringValues stringValues)
|
|
||||||
{
|
|
||||||
Assert.Null((string[])stringValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(DefaultOrNullStringValues))]
|
|
||||||
[MemberData(nameof(EmptyStringValues))]
|
|
||||||
public void DefaultNullOrEmpty_ExpectedValues(StringValues stringValues)
|
|
||||||
{
|
|
||||||
Assert.Equal(0, stringValues.Count);
|
|
||||||
Assert.Null((string)stringValues);
|
|
||||||
Assert.Equal((string)null, stringValues);
|
|
||||||
Assert.Equal(string.Empty, stringValues.ToString());
|
|
||||||
Assert.Equal(new string[0], stringValues.ToArray());
|
|
||||||
|
|
||||||
Assert.True(StringValues.IsNullOrEmpty(stringValues));
|
|
||||||
Assert.Throws<IndexOutOfRangeException>(() => stringValues[0]);
|
|
||||||
Assert.Throws<IndexOutOfRangeException>(() => ((IList<string>)stringValues)[0]);
|
|
||||||
Assert.Equal(string.Empty, stringValues.ToString());
|
|
||||||
Assert.Equal(-1, ((IList<string>)stringValues).IndexOf(null));
|
|
||||||
Assert.Equal(-1, ((IList<string>)stringValues).IndexOf(string.Empty));
|
|
||||||
Assert.Equal(-1, ((IList<string>)stringValues).IndexOf("not there"));
|
|
||||||
Assert.False(((ICollection<string>)stringValues).Contains(null));
|
|
||||||
Assert.False(((ICollection<string>)stringValues).Contains(string.Empty));
|
|
||||||
Assert.False(((ICollection<string>)stringValues).Contains("not there"));
|
|
||||||
Assert.Equal(0, stringValues.Count());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void ImplicitStringConverter_Works()
|
|
||||||
{
|
|
||||||
string nullString = null;
|
|
||||||
StringValues stringValues = nullString;
|
|
||||||
Assert.Equal(0, stringValues.Count);
|
|
||||||
Assert.Null((string)stringValues);
|
|
||||||
Assert.Null((string[])stringValues);
|
|
||||||
|
|
||||||
string aString = "abc";
|
|
||||||
stringValues = aString;
|
|
||||||
Assert.Equal(1, stringValues.Count);
|
|
||||||
Assert.Equal(aString, stringValues);
|
|
||||||
Assert.Equal(aString, stringValues[0]);
|
|
||||||
Assert.Equal(aString, ((IList<string>)stringValues)[0]);
|
|
||||||
Assert.Equal<string[]>(new string[] { aString }, stringValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void ImplicitStringArrayConverter_Works()
|
|
||||||
{
|
|
||||||
string[] nullStringArray = null;
|
|
||||||
StringValues stringValues = nullStringArray;
|
|
||||||
Assert.Equal(0, stringValues.Count);
|
|
||||||
Assert.Null((string)stringValues);
|
|
||||||
Assert.Null((string[])stringValues);
|
|
||||||
|
|
||||||
string aString = "abc";
|
|
||||||
string[] aStringArray = new[] { aString };
|
|
||||||
stringValues = aStringArray;
|
|
||||||
Assert.Equal(1, stringValues.Count);
|
|
||||||
Assert.Equal(aString, stringValues);
|
|
||||||
Assert.Equal(aString, stringValues[0]);
|
|
||||||
Assert.Equal(aString, ((IList<string>)stringValues)[0]);
|
|
||||||
Assert.Equal<string[]>(aStringArray, stringValues);
|
|
||||||
|
|
||||||
aString = "abc";
|
|
||||||
string bString = "bcd";
|
|
||||||
aStringArray = new[] { aString, bString };
|
|
||||||
stringValues = aStringArray;
|
|
||||||
Assert.Equal(2, stringValues.Count);
|
|
||||||
Assert.Equal("abc,bcd", stringValues);
|
|
||||||
Assert.Equal<string[]>(aStringArray, stringValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(DefaultOrNullStringValues))]
|
|
||||||
[MemberData(nameof(EmptyStringValues))]
|
|
||||||
public void DefaultNullOrEmpty_Enumerator(StringValues stringValues)
|
|
||||||
{
|
|
||||||
var e = stringValues.GetEnumerator();
|
|
||||||
Assert.Null(e.Current);
|
|
||||||
Assert.False(e.MoveNext());
|
|
||||||
Assert.Null(e.Current);
|
|
||||||
Assert.False(e.MoveNext());
|
|
||||||
Assert.False(e.MoveNext());
|
|
||||||
Assert.False(e.MoveNext());
|
|
||||||
|
|
||||||
var e1 = ((IEnumerable<string>)stringValues).GetEnumerator();
|
|
||||||
Assert.Null(e1.Current);
|
|
||||||
Assert.False(e1.MoveNext());
|
|
||||||
Assert.Null(e1.Current);
|
|
||||||
Assert.False(e1.MoveNext());
|
|
||||||
Assert.False(e1.MoveNext());
|
|
||||||
Assert.False(e1.MoveNext());
|
|
||||||
|
|
||||||
var e2 = ((IEnumerable)stringValues).GetEnumerator();
|
|
||||||
Assert.Null(e2.Current);
|
|
||||||
Assert.False(e2.MoveNext());
|
|
||||||
Assert.Null(e2.Current);
|
|
||||||
Assert.False(e2.MoveNext());
|
|
||||||
Assert.False(e2.MoveNext());
|
|
||||||
Assert.False(e2.MoveNext());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(FilledStringValuesWithExpected))]
|
|
||||||
public void Enumerator(StringValues stringValues, string[] expected)
|
|
||||||
{
|
|
||||||
var e = stringValues.GetEnumerator();
|
|
||||||
Assert.Null(e.Current);
|
|
||||||
for (int i = 0; i < expected.Length; i++)
|
|
||||||
{
|
|
||||||
Assert.True(e.MoveNext());
|
|
||||||
Assert.Equal(expected[i], e.Current);
|
|
||||||
}
|
|
||||||
Assert.False(e.MoveNext());
|
|
||||||
Assert.False(e.MoveNext());
|
|
||||||
Assert.False(e.MoveNext());
|
|
||||||
|
|
||||||
var e1 = ((IEnumerable<string>)stringValues).GetEnumerator();
|
|
||||||
Assert.Null(e1.Current);
|
|
||||||
for (int i = 0; i < expected.Length; i++)
|
|
||||||
{
|
|
||||||
Assert.True(e1.MoveNext());
|
|
||||||
Assert.Equal(expected[i], e1.Current);
|
|
||||||
}
|
|
||||||
Assert.False(e1.MoveNext());
|
|
||||||
Assert.False(e1.MoveNext());
|
|
||||||
Assert.False(e1.MoveNext());
|
|
||||||
|
|
||||||
var e2 = ((IEnumerable)stringValues).GetEnumerator();
|
|
||||||
Assert.Null(e2.Current);
|
|
||||||
for (int i = 0; i < expected.Length; i++)
|
|
||||||
{
|
|
||||||
Assert.True(e2.MoveNext());
|
|
||||||
Assert.Equal(expected[i], e2.Current);
|
|
||||||
}
|
|
||||||
Assert.False(e2.MoveNext());
|
|
||||||
Assert.False(e2.MoveNext());
|
|
||||||
Assert.False(e2.MoveNext());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(FilledStringValuesWithExpected))]
|
|
||||||
public void IndexOf(StringValues stringValues, string[] expected)
|
|
||||||
{
|
|
||||||
IList<string> list = stringValues;
|
|
||||||
Assert.Equal(-1, list.IndexOf("not there"));
|
|
||||||
for (int i = 0; i < expected.Length; i++)
|
|
||||||
{
|
|
||||||
Assert.Equal(i, list.IndexOf(expected[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(FilledStringValuesWithExpected))]
|
|
||||||
public void Contains(StringValues stringValues, string[] expected)
|
|
||||||
{
|
|
||||||
ICollection<string> collection = stringValues;
|
|
||||||
Assert.False(collection.Contains("not there"));
|
|
||||||
for (int i = 0; i < expected.Length; i++)
|
|
||||||
{
|
|
||||||
Assert.True(collection.Contains(expected[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(FilledStringValuesWithExpected))]
|
|
||||||
public void CopyTo(StringValues stringValues, string[] expected)
|
|
||||||
{
|
|
||||||
ICollection<string> collection = stringValues;
|
|
||||||
|
|
||||||
string[] tooSmall = new string[0];
|
|
||||||
Assert.Throws<ArgumentException>(() => collection.CopyTo(tooSmall, 0));
|
|
||||||
|
|
||||||
string[] actual = new string[expected.Length];
|
|
||||||
Assert.Throws<ArgumentOutOfRangeException>(() => collection.CopyTo(actual, -1));
|
|
||||||
Assert.Throws<ArgumentException>(() => collection.CopyTo(actual, actual.Length + 1));
|
|
||||||
collection.CopyTo(actual, 0);
|
|
||||||
Assert.Equal(expected, actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(DefaultOrNullStringValues))]
|
|
||||||
[MemberData(nameof(EmptyStringValues))]
|
|
||||||
public void DefaultNullOrEmpty_Concat(StringValues stringValues)
|
|
||||||
{
|
|
||||||
string[] expected = new[] { "abc", "bcd", "foo" };
|
|
||||||
Assert.Equal(expected, StringValues.Concat(stringValues, new StringValues(expected)));
|
|
||||||
Assert.Equal(expected, StringValues.Concat(new StringValues(expected), stringValues));
|
|
||||||
|
|
||||||
string[] empty = new string[0];
|
|
||||||
Assert.Equal(empty, StringValues.Concat(stringValues, StringValues.Empty));
|
|
||||||
Assert.Equal(empty, StringValues.Concat(StringValues.Empty, stringValues));
|
|
||||||
Assert.Equal(empty, StringValues.Concat(stringValues, new StringValues()));
|
|
||||||
Assert.Equal(empty, StringValues.Concat(new StringValues(), stringValues));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Theory]
|
|
||||||
[MemberData(nameof(FilledStringValuesWithExpected))]
|
|
||||||
public void Concat(StringValues stringValues, string[] array)
|
|
||||||
{
|
|
||||||
string[] filled = new[] { "abc", "bcd", "foo" };
|
|
||||||
|
|
||||||
string[] expectedPrepended = array.Concat(filled).ToArray();
|
|
||||||
Assert.Equal(expectedPrepended, StringValues.Concat(stringValues, new StringValues(filled)));
|
|
||||||
|
|
||||||
string[] expectedAppended = filled.Concat(array).ToArray();
|
|
||||||
Assert.Equal(expectedAppended, StringValues.Concat(new StringValues(filled), stringValues));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"Microsoft.Framework.Primitives": "1.0.0-*",
|
|
||||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
|
||||||
},
|
|
||||||
"commands": {
|
|
||||||
"test": "xunit.runner.aspnet"
|
|
||||||
},
|
|
||||||
"frameworks": {
|
|
||||||
"dnx451": { },
|
|
||||||
"dnxcore50": { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue