Skip to content

Commit

Permalink
Replace binary formatter (#8532)
Browse files Browse the repository at this point in the history
* Replace BF for string input

* Replacing BF

* Updated BinaryFormattedObjectExtension

* Replacing BF in DataStreams

* Fixing Build for test

* Updating comments

* Adding fall back to BinaryFormatter

* Adding UnitTest setup

* Adding more BinaryFormatWriter test

* Adding more unit tests

* Adding BinaryFormattedObjectTests

* Replacing Binaries before Unit Tests

* Updating copy-wpf.ps1

* Resolving Replace binaries issue

* Adding UnitTest setup

* Adding more BinaryFormatWriter test

* Adding more unit tests

* Adding BinaryFormattedObjectTests

* Replacing Binaries before Unit Tests

* Updating copy-wpf.ps1

* Resolving Replace binaries issue

* excluding DirectWriteForwarder for copy command

* disable replace naive binaries

* updating args data type

* Replace BF for string input

* Replacing BF

* Updated BinaryFormattedObjectExtension

* Replacing BF in DataStreams

* Fixing Build for test

* Updating comments

* Adding fall back to BinaryFormatter

* Adding UnitTest setup

* Adding more BinaryFormatWriter test

* Adding more unit tests

* Adding BinaryFormattedObjectTests

* Replacing Binaries before Unit Tests

* Updating copy-wpf.ps1

* Resolving Replace binaries issue

* excluding DirectWriteForwarder for copy command

* Adding UnitTest setup

* Adding more BinaryFormatWriter test

* Adding more unit tests

* disable replace naive binaries

* updating args data type

* updating pipeline-pr.yml

* Replace BF for string input

* Replacing BF

* Updated BinaryFormattedObjectExtension

* Replacing BF in DataStreams

* Fixing Build for test

* Updating comments

* Adding fall back to BinaryFormatter

* Adding UnitTest setup

* Adding more BinaryFormatWriter test

* Adding more unit tests

* Adding BinaryFormattedObjectTests

* Replacing Binaries before Unit Tests

* Updating copy-wpf.ps1

* Resolving Replace binaries issue

* excluding DirectWriteForwarder for copy command

* Adding UnitTest setup

* Adding more BinaryFormatWriter test

* Adding more unit tests

* disable replace naive binaries

* updating args data type

* updating pipeline-pr.yml

* Replace BF for string input

* Replacing BF

* Replacing BF in DataStreams

* Updating comments

* Adding fall back to BinaryFormatter

* Adding more BinaryFormatWriter test

* Adding more unit tests

* Adding more BinaryFormatWriter test

* Adding more unit tests

* Remove commented code and add correct indentation

* Add "System.Runtime.Serialization.Formatters" reference in unit test

* Disabling PresentationCore.Tests [Temp]

* Revert Replace binaries before test

* Fix indentation

* Update Release | x86 type for SystemXamlTest

* Update Write-host to wirte-debug for debug statement
  • Loading branch information
rchauhan18 authored Jul 19, 2024
1 parent 321e201 commit f29acba
Show file tree
Hide file tree
Showing 87 changed files with 6,424 additions and 28 deletions.
6 changes: 3 additions & 3 deletions Microsoft.Dotnet.Wpf.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28815.4
# Visual Studio Version 17
VisualStudioVersion = 17.9.34407.89
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xaml", "src\Microsoft.DotNet.Wpf\src\System.Xaml\System.Xaml.csproj", "{9AC36357-34B7-40A1-95CA-FE9F46D089A7}"
EndProject
Expand Down Expand Up @@ -247,7 +247,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{34B64A4A
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UnitTests", "UnitTests", "{A48B585E-6AB0-4F8D-8484-77F37CB44437}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Xaml.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\System.Xaml.Tests\System.Xaml.Tests.csproj", "{B2F2A89C-55C9-41B1-A645-0948609BD8BE}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFB}") = "System.Xaml.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\System.Xaml.Tests\System.Xaml.Tests.csproj", "{B2F2A89C-55C9-41B1-A645-0948609BD8BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PresentationFramework.Fluent", "src\Microsoft.DotNet.Wpf\src\Themes\PresentationFramework.Fluent\PresentationFramework.Fluent.csproj", "{3F2C0E0E-BB13-46D9-8D9A-08256A49ECA9}"
EndProject
Expand Down
18 changes: 15 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@
<PropertyGroup>
<MicrosoftBuildFrameworkPackageVersion>15.9.20</MicrosoftBuildFrameworkPackageVersion>
<MicrosoftBuildUtilitiesCorePackageVersion>15.9.20</MicrosoftBuildUtilitiesCorePackageVersion>
<XUnitVersion>2.4.0</XUnitVersion>
<XUnitRunnerConsoleVersion>$(XUnitVersion)</XUnitRunnerConsoleVersion>
<XUnitRunnerVisualStudioVersion>$(XUnitVersion)</XUnitRunnerVisualStudioVersion>

<!--
Also in global.json
Used in Wpf.Cpp.PrivateTools.props/targets
Expand All @@ -87,9 +85,23 @@
<PropertyGroup>
<MicrosoftCodeAnalysisNetAnalyzersVersion>7.0.0</MicrosoftCodeAnalysisNetAnalyzersVersion>
</PropertyGroup>
<!-- XUnit-related (not extensions) -->
<PropertyGroup>
<XUnitVersion>2.6.1</XUnitVersion>
<XUnitAssertVersion>$(XUnitVersion)</XUnitAssertVersion>
<XUnitRunnerConsoleVersion>$(XUnitVersion)</XUnitRunnerConsoleVersion>
<XUnitRunnerVisualStudioVersion>2.4.3</XUnitRunnerVisualStudioVersion>
<XUnitExtensibilityExecutionVersion>$(XUnitVersion)</XUnitExtensibilityExecutionVersion>
<XUnitStaFactPackageVersion>1.2.46-alpha</XUnitStaFactPackageVersion>
</PropertyGroup>
<!-- Test related -->
<PropertyGroup>
<MoqPackageVersion>4.10.0</MoqPackageVersion>
<FluentAssertionsVersion>6.11.0</FluentAssertionsVersion>
<SystemComponentModelTypeConverterTestDataVersion>8.0.0-beta.23107.1</SystemComponentModelTypeConverterTestDataVersion>
<SystemDrawingCommonTestDataVersion>8.0.0-beta.23107.1</SystemDrawingCommonTestDataVersion>
<SystemWindowsExtensionsTestDataVersion>8.0.0-beta.23107.1</SystemWindowsExtensionsTestDataVersion>
<VerifyXunitVersion>14.2.0</VerifyXunitVersion>
</PropertyGroup>
<!-- Code Coverage -->
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion eng/WpfArcadeSdk/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PropertyGroup>
<GenXmlStringTable>$(WpfArcadeSdkToolsDir)GenXmlStringTable.pl</GenXmlStringTable>
<LangVersion Condition="'$(LangVersion)'=='' and ($(PreReleaseVersionLabel.Contains('rc')) or $(PreReleaseVersionLabel.Contains('preview')) or $(PreReleaseVersionLabel.Contains('alpha')))">preview</LangVersion>
<LangVersion Condition="'$(LangVersion)'==''">10</LangVersion>
<LangVersion Condition="'$(LangVersion)'==''">11</LangVersion>
<CLSCompliant Condition="'$(CLSCompliant)'==''">true</CLSCompliant>
<IncludeDllSafeSearchPathAttribute Condition="'$(IncludeDllSafeSearchPathAttribute )'==''">true</IncludeDllSafeSearchPathAttribute>

Expand Down
37 changes: 30 additions & 7 deletions eng/copy-wpf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ function Print-Usage()
Write-Host "*** Copy WPF files procedure ***"

$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
Write-Debug ("Repo root = " + $RepoRoot)
$Config = if ($release) { "Release" } else { "Debug" }

Write-Host "Target architecture - configuration: " $arch $Config
Write-Debug ("Target architecture - configuration: " + $arch + $Config)

function CopyBinariesToLocation($location)
{
$locallyBuiltBinaryLocationBase = Join-Path $RepoRoot "artifacts\packaging"
Write-Debug ("locallyBuiltBinaryLocationBase = " + $locallyBuiltBinaryLocationBase)

Write-Host "Copy native binaries..."
CopyNativeBinariesToLocation $location $locallyBuiltBinaryLocationBase
# Write-Host "Copy native binaries..."
# CopyNativeBinariesToLocation $location $locallyBuiltBinaryLocationBase

Write-Host "Copy managed binaries..."
CopyManagedBinariesToLocation $location $locallyBuiltBinaryLocationBase
Expand All @@ -53,8 +55,26 @@ function CopyNativeBinariesToLocation($location, $localBinLocation)
# x64 - artifacts\packaging\Debug\x64\Microsoft.DotNet.Wpf.GitHub\lib\win-x64

$PackageName = "Microsoft.DotNet.Wpf.GitHub"
$PackageName += if ($release) { "" } else { ".Debug" }
$BinaryLocationInPackage = "win-$arch"
CopyPackagedBinaries $location $localBinLocation $PackageName $BinaryLocationInPackage
# CopyPackagedBinaries $location $localBinLocation $PackageName $BinaryLocationInPackage

$ArchFolder = if ($arch -eq "x86") { "" } else { "x64" }
$BinLocation = [System.IO.Path]::Combine($localBinLocation, $Config, $ArchFolder, $packageName, "runtimes", $binaryLocationInPackage,"native" , "*")
Write-Debug ("Native binLocation = " + $BinLocation)

if (Test-Path $BinLocation)
{
Copy-Item -path $BinLocation -include "*.dll","*.pdb" -Destination $location
Write-Host "All files are copied" -ForegroundColor Green
}
else
{
Write-Host "Source files location unavailable: " $BinLocation -ForegroundColor Yellow -NoNewline
Write-Host " Skip. No file has been copied."
return
}

}
function CopyManagedBinariesToLocation($location, $localBinLocation)
{
Expand All @@ -63,17 +83,20 @@ function CopyManagedBinariesToLocation($location, $localBinLocation)
# x64 - artifacts\packaging\Debug\x64\Microsoft.DotNet.Wpf.GitHub\lib\net6.0

$PackageName = "Microsoft.DotNet.Wpf.GitHub"
$BinaryLocationInPackage = "net8.0"
$PackageName += if ($release) { "" } else { ".Debug" }
$BinaryLocationInPackage = "net9.0"
CopyPackagedBinaries $location $localBinLocation $PackageName $BinaryLocationInPackage
}

function CopyPackagedBinaries($location, $localBinLocation, $packageName, $binaryLocationInPackage)
{
$ArchFolder = if ($arch -eq "x86") { "" } else { "x64" }
$BinLocation = [System.IO.Path]::Combine($localBinLocation, $Config, $ArchFolder, $packageName, "lib", $binaryLocationInPackage, "*")
Write-Debug ("binLocation = " + $BinLocation)

if (Test-Path $BinLocation)
{
Copy-Item -path $BinLocation -include "*.dll","*.pdb" -Destination $location
Copy-Item -path $BinLocation -include "*.dll","*.pdb" -Destination $location -Exclude DirectWriteForwarder.*
Write-Host "All files are copied" -ForegroundColor Green
}
else
Expand Down Expand Up @@ -153,7 +176,7 @@ elseif($testhost)
else
{
$runtimeIdentifer = "win-$arch"
$location = [System.IO.Path]::Combine($destination, "bin\Debug\net8.0", $runtimeIdentifer, "publish")
$location = [System.IO.Path]::Combine($destination, "bin\Debug\net9.0", $runtimeIdentifer, "publish")
if(![System.IO.Directory]::Exists($location))
{
Write-Host "App publishing directory unavailable: " $location -ForegroundColor Red
Expand Down
11 changes: 10 additions & 1 deletion eng/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ jobs:
# (!_HelixPipeline) ||
# (_HelixPipeline && _PublicBuildPipeline && _ContinuousIntegrationTestsEnabled && _BuildConfig == Release)
condition: or(ne(variables['_HelixPipeline'], 'true'), and(eq(variables['_HelixPipeline'], 'true') ,eq(variables['_BuildConfig'], 'Release'), eq(variables['_PublicBuildPipeline'], 'true'), eq(variables['_ContinuousIntegrationTestsEnabled'], 'true')))
- script: eng\scripts\ciunittest.cmd -configuration $(_BuildConfig) -prepareMachine $(_PublishArgs) $(_SignArgs) $(_OfficialBuildIdArgs) $(_PlatformArgs) $(_InternalRuntimeDownloadArgs)

- script: eng\scripts\ciunittest.cmd
-configuration $(_BuildConfig)
-prepareMachine
$(_PublishArgs)
$(_SignArgs)
$(_OfficialBuildIdArgs)
$(_PlatformArgs)
$(_InternalRuntimeDownloadArgs)
displayName: Run xUnit Tests
condition: and(or(ne(variables['_HelixPipeline'], 'true'), and(eq(variables['_HelixPipeline'], 'true') ,eq(variables['_BuildConfig'], 'Release'), eq(variables['_PublicBuildPipeline'], 'true'), eq(variables['_ContinuousIntegrationTestsEnabled'], 'true'))), ne(variables['_Platform'], 'arm64'))
- task: PublishTestResults@2
Expand Down Expand Up @@ -193,6 +201,7 @@ jobs:
targetType: 'inline'
script: '.\eng\copy-wpf.ps1 -testhost -destination .dotnet -$(_BuildConfig) -arch $(_Platform)'
condition: and(eq(variables['System.TeamProject'], 'public'), ne(variables['_Platform'], 'arm64'))

- task: DownloadPipelineArtifact@2
displayName: Fetch Test Binaries
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[assembly:InternalsVisibleTo(BuildInfo.PresentationFrameworkSystemDrawing)]
[assembly:InternalsVisibleTo(BuildInfo.SystemWindowsControlsRibbon)]
[assembly:InternalsVisibleTo(BuildInfo.WindowsFormsIntegration)]

[assembly:InternalsVisibleTo("PresentationCore.Tests,PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
[assembly: TypeForwardedTo(typeof(System.Windows.Markup.IUriContext))]
[assembly: TypeForwardedTo(typeof(System.Windows.Media.TextFormattingMode))]
[assembly: TypeForwardedTo(typeof(System.Windows.Input.ICommand))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Compile Include="$(WpfCommonDir)src\System\SR.cs">
<Link>Common\System\SR.cs</Link>
</Compile>

<Compile Include="$(WpfCommonDir)\Graphics\wgx_error.cs" />
<Compile Include="$(WpfCommonDir)\Graphics\wgx_render.cs" />
<Compile Include="$(WpfCommonDir)\Graphics\wgx_exports.cs" />
Expand Down Expand Up @@ -333,6 +334,57 @@
<Compile Include="System\Windows\DataFormat.cs" />
<Compile Include="System\Windows\DataFormats.cs" />
<Compile Include="System\Windows\dataobject.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryFormatWriter.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryFormatWriterScope.cs" />
<Compile Include="System\Windows\BinaryFormat\ExceptionExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryObjectString.cs" />
<Compile Include="System\Windows\BinaryFormat\IBinaryFormatParseable.cs" />
<Compile Include="System\Windows\BinaryFormat\IBinaryWriteable.cs" />
<Compile Include="System\Windows\BinaryFormat\MemberTypeInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\Id.cs" />
<Compile Include="System\Windows\BinaryFormat\IRecord.cs" />
<Compile Include="System\Windows\BinaryFormat\RecordMap.cs" />
<Compile Include="System\Windows\BinaryFormat\RecordType.cs" />
<Compile Include="System\Windows\BinaryFormat\NullableAttributes.cs" />
<Compile Include="System\Windows\BinaryFormat\ListConverterHelper.cs" />
<Compile Include="System\Windows\BinaryFormat\FormatterConverterStub.cs" />
<Compile Include="System\Windows\BinaryFormat\SerializationExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryFormattedObject.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryFormattedObjectExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\MessageEnd.cs" />
<Compile Include="System\Windows\BinaryFormat\Record.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryType.cs" />
<Compile Include="System\Windows\BinaryFormat\PrimitiveType.cs" />
<Compile Include="System\Windows\BinaryFormat\Count.cs" />
<Compile Include="System\Windows\BinaryFormat\NullRecord.cs" />
<Compile Include="System\Windows\BinaryFormat\ObjectNull.cs" />
<Compile Include="System\Windows\BinaryFormat\ArraySingleString.cs" />
<Compile Include="System\Windows\BinaryFormat\ArrayRecord.cs" />
<Compile Include="System\Windows\BinaryFormat\ArrayInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\ArraySingleObject.cs" />
<Compile Include="System\Windows\BinaryFormat\ArraySinglePrimitive.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryLibrary.cs" />
<Compile Include="System\Windows\BinaryFormat\MemberReference.cs" />
<Compile Include="System\Windows\BinaryFormat\MemberPrimitiveTyped.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryArray.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassWithMembersAndTypes.cs" />
<Compile Include="System\Windows\BinaryFormat\SystemClassWithMembersAndTypes.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassRecord.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassWithId.cs" />
<Compile Include="System\Windows\BinaryFormat\TypeInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassWithMembers.cs" />
<Compile Include="System\Windows\BinaryFormat\SystemClassWithMembers.cs" />
<Compile Include="System\Windows\BinaryFormat\SerializationHeader.cs" />
<Compile Include="System\Windows\BinaryFormat\ClassTypeInfo.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryArrayType.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryReaderExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\BinaryWriterExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\IntrinsicExtensions.cs" />
<Compile Include="System\Windows\BinaryFormat\NullRecord.ObjectNullMultiple.cs" />
<Compile Include="System\Windows\BinaryFormat\NullRecord.ObjectNullMultiple256.cs" />
<Compile Include="System\Windows\BinaryFormat\StringRecordsCollection.cs" />
<Compile Include="System\Windows\BinaryFormat\ListConverter.cs" />
<Compile Include="System\Windows\DataObjectCopyingEventArgs.cs" />
<Compile Include="System\Windows\DataObjectEventArgs.cs" />
<Compile Include="System\Windows\DataObjectPastingEventArgs.cs" />
Expand Down Expand Up @@ -1397,6 +1449,7 @@
<NetCoreReference Include="System.Diagnostics.Tools" />
<NetCoreReference Include="System.Diagnostics.TraceSource" />
<NetCoreReference Include="System.Diagnostics.Tracing" />
<NetCoreReference Include="System.Drawing.Primitives" />
<NetCoreReference Include="System.IO.FileSystem" />
<NetCoreReference Include="System.Memory" />
<NetCoreReference Include="System.Net.Primitives" />
Expand All @@ -1411,6 +1464,8 @@
<NetCoreReference Include="System.Text.Encoding.Extensions" />
<NetCoreReference Include="System.Text.RegularExpressions" />
<NetCoreReference Include="System.Threading" />
<NetCoreReference Include="System.Collections.Generic" />
<NetCoreReference Include="System.Linq" />
<NetCoreReference Include="System.Threading.Tasks" />
<NetCoreReference Include="System.Threading.Thread" />
<NetCoreReference Include="System.Threading.ThreadPool" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.IO;

namespace System.Windows
{
/// <summary>
/// Array information structure.
/// </summary>
/// <remarks>
/// <para>
/// <see href="https://learn.microsoft.com/openspecs/windows_protocols/ms-nrbf/8fac763f-e46d-43a1-b360-80eb83d2c5fb">
/// [MS-NRBF] 2.4.2.1
/// </see>
/// </para>
/// </remarks>
internal readonly struct ArrayInfo : IBinaryWriteable
{
public Id ObjectId { get; }
public Count Length { get; }

public ArrayInfo(Id objectId, Count length)
{
Length = length;
ObjectId = objectId;
}

public static ArrayInfo Parse(BinaryReader reader, out Count length)
{
ArrayInfo arrayInfo = new(reader.ReadInt32(), reader.ReadInt32());
length = arrayInfo.Length;
return arrayInfo;
}

public readonly void Write(BinaryWriter writer)
{
writer.Write(ObjectId);
writer.Write(Length);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.


using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace System.Windows
{
/// <summary>
/// Base class for array records.
/// </summary>
/// <devdoc>
/// <see href="https://learn.microsoft.com/openspecs/windows_protocols/ms-nrbf/f57d41e5-d3c0-4340-add8-fa4449a68d1c">
/// [MS-NRBF] 2.4</see> describes how item records must follow the array record and how multiple null records
/// can be coalesced into an <see cref="NullRecord.ObjectNullMultiple"/> or <see cref="NullRecord.ObjectNullMultiple256"/>
/// record.
/// </devdoc>
internal abstract class ArrayRecord : Record, IEnumerable<object>
{
public ArrayInfo ArrayInfo { get; }

/// <summary>
/// The array items.
/// </summary>
/// <remarks>
/// <para>
/// Multi-null records are always expanded to individual <see cref="ObjectNull"/> entries when reading.
/// </para>
/// </remarks>
public IReadOnlyList<object> ArrayObjects { get; }

/// <summary>
/// Identifier for the array.
/// </summary>
public Id ObjectId => ArrayInfo.ObjectId;

/// <summary>
/// Length of the array.
/// </summary>
public Count Length => ArrayInfo.Length;

/// <summary>
/// Returns the item at the given index.
/// </summary>
public object this[int index] => ArrayObjects[index];

public ArrayRecord(ArrayInfo arrayInfo, IReadOnlyList<object> arrayObjects)
{
if (arrayInfo.Length != arrayObjects.Count)
{
throw new ArgumentException($"{nameof(arrayInfo)} doesn't match count of {nameof(arrayObjects)}");
}

ArrayInfo = arrayInfo;
ArrayObjects = arrayObjects;
}

IEnumerator<object> IEnumerable<object>.GetEnumerator() => ArrayObjects.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => ArrayObjects.GetEnumerator();
}
}
Loading

0 comments on commit f29acba

Please sign in to comment.