Skip to content

Commit dbed62f

Browse files
committed
Upload sources
1 parent dea2435 commit dbed62f

File tree

3 files changed

+129
-1
lines changed

3 files changed

+129
-1
lines changed

ArrayDeconstructors.Source.nuspec

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
3+
<metadata>
4+
<id>ArrayDeconstructors.Source</id>
5+
<version>1.0.1</version>
6+
<authors>Alexander Zaytsev</authors>
7+
<owners>hazzik</owners>
8+
<licenseUrl>https://opensource.org/licenses/MIT</licenseUrl>
9+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
10+
<description>ArrayDeconstructors is a source package which allows you to use new C# 7 deconstruction syntax to deconstruct array into variables:
11+
12+
int[] array = <...>;
13+
var (a,b) = array;</description>
14+
<copyright>Alexander Zaytsev © 2017</copyright>
15+
<tags>deconstructor deconstruction array arrays</tags>
16+
</metadata>
17+
<files>
18+
<file src="ArrayDeconstructors.cs.pp" target="content\App_Code\ArrayDeconstructors.cs.pp" />
19+
</files>
20+
</package>

ArrayDeconstructors.cs.pp

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#region LICENSE
2+
/**
3+
MIT License
4+
5+
Copyright(c) 2017 Alexander Zaytsev
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
24+
*/
25+
#endregion
26+
namespace $rootnamespace$
27+
{
28+
public static class ArrayDeconstructors
29+
{
30+
public static void Deconstruct<T>(this T[] array, out T t1)
31+
{
32+
t1 = array[0];
33+
}
34+
public static void Deconstruct<T>(this T[] array, out T t1, out T t2)
35+
{
36+
t1 = array[0];
37+
t2 = array[1];
38+
}
39+
public static void Deconstruct<T>(this T[] array, out T t1, out T t2, out T t3)
40+
{
41+
t1 = array[0];
42+
t2 = array[1];
43+
t3 = array[2];
44+
}
45+
public static void Deconstruct<T>(this T[] array, out T t1, out T t2, out T t3, out T t4)
46+
{
47+
t1 = array[0];
48+
t2 = array[1];
49+
t3 = array[2];
50+
t4 = array[3];
51+
}
52+
public static void Deconstruct<T>(this T[] array, out T t1, out T t2, out T t3, out T t4, out T t5)
53+
{
54+
t1 = array[0];
55+
t2 = array[1];
56+
t3 = array[2];
57+
t4 = array[3];
58+
t5 = array[4];
59+
}
60+
public static void Deconstruct<T>(this T[] array, out T t1, out T t2, out T t3, out T t4, out T t5, out T t6)
61+
{
62+
t1 = array[0];
63+
t2 = array[1];
64+
t3 = array[2];
65+
t4 = array[3];
66+
t5 = array[4];
67+
t6 = array[5];
68+
}
69+
public static void Deconstruct<T>(this T[] array, out T t1, out T t2, out T t3, out T t4, out T t5, out T t6, out T t7)
70+
{
71+
t1 = array[0];
72+
t2 = array[1];
73+
t3 = array[2];
74+
t4 = array[3];
75+
t5 = array[4];
76+
t6 = array[5];
77+
t7 = array[6];
78+
}
79+
public static void Deconstruct<T>(this T[] array, out T t1, out T t2, out T t3, out T t4, out T t5, out T t6, out T t7, out T t8)
80+
{
81+
t1 = array[0];
82+
t2 = array[1];
83+
t3 = array[2];
84+
t4 = array[3];
85+
t5 = array[4];
86+
t6 = array[5];
87+
t7 = array[6];
88+
t8 = array[7];
89+
}
90+
}
91+
}

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
# ArrayDeconstructors
1+
# ArrayDeconstructors
2+
3+
ArrayDeconstructors is a source package which allows you to use new C# 7 deconstruction syntax to deconstruct array into variables:
4+
5+
int[] array = <...>;
6+
var (a,b) = array;
7+
8+
## Implementation notes
9+
10+
the decision has been made such that there are no safety checks on the deconstruction methods.
11+
12+
## Installation
13+
14+
You can install from [NuGet](https://nuget.org/packages/ArrayDeconstructors.Source/) using following command:
15+
16+
```
17+
> Install-Package ArrayDeconstructors.Source
18+
```

0 commit comments

Comments
 (0)