Fluentsoft.Generators
1.0.7
dotnet add package Fluentsoft.Generators --version 1.0.7
NuGet\Install-Package Fluentsoft.Generators -Version 1.0.7
<PackageReference Include="Fluentsoft.Generators" Version="1.0.7" />
paket add Fluentsoft.Generators --version 1.0.7
#r "nuget: Fluentsoft.Generators, 1.0.7"
// Install Fluentsoft.Generators as a Cake Addin #addin nuget:?package=Fluentsoft.Generators&version=1.0.7 // Install Fluentsoft.Generators as a Cake Tool #tool nuget:?package=Fluentsoft.Generators&version=1.0.7
Fluentsoft Generators
Package: Fluentsoft.Generators
Assembly: fluentsoft.generators.dll, fluentsoft.generators.runtime.dll
Value Arrays
Generates value array of fixed size.
ValueArrayAttribute<T> class
where T : unmanaged
Namespace: Fluentsoft.System
Assembly: fluentsoft.generators.runtime.dll
Marks a struct as a placeholder for value array:
[ValueArray<int>(5)]
public partial struct ValueArrayStruct { }
Remarks
When struct marked by ValueArray attribute, the code generator add folowing members to the struct type
The StructTypeName is a name of struct the ValueArrayAttribute applied to.
The ElementTypeName is a name of array element type.
Constructors
StructTypeName(Span<ElementTypeName> source) |
StructTypeName(Memory<ElementTypeName> source) |
StructTypeName(ElementTypeName[] source) |
Members
Member | Description |
---|---|
const int Length | Length of the array |
Type ElementType | The type of array's element |
int Count | Number of item in the array |
Span<ElementTypeName> Span | |
ref ElementTypeName this[Index idx] |
Methods
Method | Description |
---|---|
ToArray() | Copy all items to resulting array |
CopyTo(ElementTypeName[] target, int index) | Copies all the elements of the current one-dimensional array to the specified one-dimensional array starting at the specified destination array index. |
CopyTo(Span<ElementTypeName> target) | Copies the contents of this array into a destination Span<T>. |
CopyTo(Memory<ElementTypeName> target) |
Operators
Operator | Description |
---|---|
impilict operator Span<ElementTypeName> | returns the Span |
Example
using Fluentsoft.System;
using Xunit;
Assert.Equal(3, ValueArrayStruct.Length);
Assert.Equal(3 * sizeof(My), sizeof(ValueArrayStruct))
var f = new ValueArrayStruct();
f[0].C = 'A';
f[1].N = 15;
var m1 = f[0];
ref var m2 = ref f[1];
Assert.Equal(f[1].N, m2.N);
m2.N = 38;
Assert.Equa;(38, f[1].N);
Assert.Throws<IndexOutOfRangeException>(() => f[3]);
var st = new MyStruct(stackalloc int[]{1,2,3,4,5});
foreach (var s in st)
{
Console.WriteLine(s);
}
Assert.Equal(new int[]{1,2,3,4,5}, st.ToArray());
public struct My
{
public char C;
public double D;
public int N;
}
[ValueArray<My>(3)]
public partial struct ValueArrayStruct { }
[ValueArray<int>(5)]
public partial struct MyStruct { }
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
uses ReadonlySpan insead of Span for initialization and as an operator