From cc1922b3ffae290bf61f7f05b83369c3eae63882 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Fri, 11 Jun 2021 11:09:25 -0700 Subject: [PATCH 01/14] Created exception for unsupported AOA asset conversion filetypes --- .../src/AssetConversionOptions.cs | 5 ++++ .../src/AssetFileType.cs | 24 ++++++++++++++++ .../src/UnsupportedAssetFileTypeException.cs | 18 ++++++++++++ .../tests/AssetConversionOptionsTests.cs | 28 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetConversionOptions.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetConversionOptions.cs index 2c250be5d1ee8..4b7c52acffeb4 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetConversionOptions.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetConversionOptions.cs @@ -77,6 +77,11 @@ internal AssetConversionOptions(Uri inputAssetUri, AssetFileType inputAssetFileT throw new ArgumentException(assetConfigurationInvalidMessage, nameof(conversionConfiguration)); } + if (!inputAssetFileType.IsValid()) + { + throw new UnsupportedAssetFileTypeException(inputAssetFileType); + } + this.InputAssetUri = inputAssetUri; this.InputAssetFileType = inputAssetFileType; this.ConversionConfiguration = conversionConfiguration; diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs index 7f2d55365ecb2..82dd7367091ce 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs @@ -2,8 +2,10 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.ComponentModel; using System.IO; +using System.Linq; namespace Azure.MixedReality.ObjectAnchors.Conversion { @@ -19,6 +21,14 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion internal const string ObjValue = ".obj"; internal const string PlyValue = ".ply"; + internal static readonly string[] validAssetFileTypeValues = new string[] { + FbxValue, + GlbValue, + GltfValue, + ObjValue, + PlyValue + }; + /// /// Initializes a new instance of the struct. /// @@ -38,6 +48,11 @@ public static AssetFileType FromFilePath(string assetFilePath) return new AssetFileType(Path.GetExtension(assetFilePath)); } + /// + /// A List of supported asset file types + /// + public static IEnumerable SupportedAssetFileTypes => validAssetFileTypeValues.Select(f => new AssetFileType(f)).AsEnumerable(); + /// /// Fbx /// @@ -104,5 +119,14 @@ public override int GetHashCode() /// public override string ToString() => _value; + + /// + /// Returns true if the values of the object contain valid data. + /// + /// true if this instance is valid; otherwise, false. + internal bool IsValid() + { + return validAssetFileTypeValues.Contains(_value, StringComparer.OrdinalIgnoreCase); + } } } diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs new file mode 100644 index 0000000000000..f7b6f36e709ae --- /dev/null +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; + +namespace Azure.MixedReality.ObjectAnchors.Conversion +{ + /// + /// An Exception thrown durin an attempt to provide an unsupported asset file type in an asset conversion operation + /// + public class UnsupportedAssetFileTypeException : Exception + { + internal UnsupportedAssetFileTypeException(AssetFileType assetFileType) + : base($"The provided asset file type of \"{assetFileType}\" is invalid. Supported file types: {string.Join(", ", AssetFileType.validAssetFileTypeValues)}") + { + } + } +} diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/AssetConversionOptionsTests.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/AssetConversionOptionsTests.cs index 27f4b2acd671d..f331b8b85126f 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/AssetConversionOptionsTests.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/AssetConversionOptionsTests.cs @@ -40,6 +40,13 @@ public AssetConversionOptionsTests(bool isAsync) : base(isAsync) new object[] { new Vector3(1, 0, 0), default(Uri), false } }; + public static IEnumerable UnsupportedAssetFileTypesFailTestData => + new List + { + new object[] { new AssetFileType(".obj"), true }, + new object[] { new AssetFileType(".exe"), false }, + }; + [Test] [TestCaseSource(nameof(IsNormalizedTestData))] public void NormalizedVectorRequired(Vector3 v, bool expectedSuccess) @@ -74,6 +81,27 @@ public void NullArgumentsFail(Vector3 v, Uri u, bool expectedSuccess) Assert.AreNotEqual(caught, expectedSuccess); } + [Test] + [TestCaseSource(nameof(UnsupportedAssetFileTypesFailTestData))] + public void UnsupportedAssetFileTypesFail(AssetFileType assetFileType, bool expectedSuccess) + { + Vector3 validAssetGravity = new Vector3(1, 0, 0); + AssetLengthUnit assetLengthUnit = AssetLengthUnit.Meters; + bool caught = false; + + try + { + new AssetConversionOptions(new Uri(anyWorkingUriString), assetFileType, validAssetGravity, assetLengthUnit); + } + catch (UnsupportedAssetFileTypeException ex) + { + Console.WriteLine(ex); + caught = true; + } + + Assert.AreNotEqual(caught, expectedSuccess); + } + [Test] public void Vector3StoresValuesCorrectly() { From 7395ab691daaa6dc95d5efd82da8fcb3dfe21594 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Fri, 11 Jun 2021 11:47:28 -0700 Subject: [PATCH 02/14] Update api file --- ...e.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs index 739559fdb121e..905cfd1d81717 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs @@ -76,6 +76,7 @@ public enum AssetConversionStatus public static Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType Gltf { get { throw null; } } public static Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType Obj { get { throw null; } } public static Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType Ply { get { throw null; } } + public static System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } public bool Equals(Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType other) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override bool Equals(object obj) { throw null; } @@ -147,6 +148,10 @@ public static partial class ObjectAnchorsConversionModelFactory [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override int GetHashCode() { throw null; } } + public partial class UnsupportedAssetFileTypeException : System.Exception + { + internal UnsupportedAssetFileTypeException() { } + } } namespace Azure.MixedReality.ObjectAnchors.Conversion.Models { From a13726927b5af8f7516639db23d68294d433f55f Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Thu, 17 Jun 2021 13:51:40 -0700 Subject: [PATCH 03/14] Add an exception for unsupported Object Anchors file formats --- .../src/AssetConversionOptions.cs | 5 --- .../src/AssetFileType.cs | 22 ----------- .../Models/AOAFrontEndAPIsModelFactory.cs | 13 +++++++ .../Models/ConversionErrorCode.cs | 13 +++++++ .../Generated/AOAFrontEndAPIsModelFactory.cs | 3 +- ...AssetConversionProperties.Serialization.cs | 1 - .../Models/AssetConversionProperties.cs | 1 - .../Generated/Models/ConversionErrorCode.cs | 2 +- .../src/ObjectAnchorsConversionClient.cs | 18 +++++++++ .../ObjectAnchorsConversionClientOptions.cs | 20 ++++++++++ .../src/UnsupportedAssetFileTypeException.cs | 17 +++++++- .../tests/AssetConversionOptionsTests.cs | 28 ------------- .../ObjectAnchorsConversionClientTests.cs | 39 +++++++++++++++++++ 13 files changed, 120 insertions(+), 62 deletions(-) create mode 100644 sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Customizations/Models/AOAFrontEndAPIsModelFactory.cs create mode 100644 sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Customizations/Models/ConversionErrorCode.cs diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetConversionOptions.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetConversionOptions.cs index 4b7c52acffeb4..2c250be5d1ee8 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetConversionOptions.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetConversionOptions.cs @@ -77,11 +77,6 @@ internal AssetConversionOptions(Uri inputAssetUri, AssetFileType inputAssetFileT throw new ArgumentException(assetConfigurationInvalidMessage, nameof(conversionConfiguration)); } - if (!inputAssetFileType.IsValid()) - { - throw new UnsupportedAssetFileTypeException(inputAssetFileType); - } - this.InputAssetUri = inputAssetUri; this.InputAssetFileType = inputAssetFileType; this.ConversionConfiguration = conversionConfiguration; diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs index 82dd7367091ce..a7e6d4a1650e2 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs @@ -21,14 +21,6 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion internal const string ObjValue = ".obj"; internal const string PlyValue = ".ply"; - internal static readonly string[] validAssetFileTypeValues = new string[] { - FbxValue, - GlbValue, - GltfValue, - ObjValue, - PlyValue - }; - /// /// Initializes a new instance of the struct. /// @@ -48,11 +40,6 @@ public static AssetFileType FromFilePath(string assetFilePath) return new AssetFileType(Path.GetExtension(assetFilePath)); } - /// - /// A List of supported asset file types - /// - public static IEnumerable SupportedAssetFileTypes => validAssetFileTypeValues.Select(f => new AssetFileType(f)).AsEnumerable(); - /// /// Fbx /// @@ -119,14 +106,5 @@ public override int GetHashCode() /// public override string ToString() => _value; - - /// - /// Returns true if the values of the object contain valid data. - /// - /// true if this instance is valid; otherwise, false. - internal bool IsValid() - { - return validAssetFileTypeValues.Contains(_value, StringComparer.OrdinalIgnoreCase); - } } } diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Customizations/Models/AOAFrontEndAPIsModelFactory.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Customizations/Models/AOAFrontEndAPIsModelFactory.cs new file mode 100644 index 0000000000000..1ddb96e3fb54f --- /dev/null +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Customizations/Models/AOAFrontEndAPIsModelFactory.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.MixedReality.ObjectAnchors.Conversion.Models; + +namespace Azure.MixedReality.ObjectAnchors.Conversion +{ + /// Model factory for read-only models. + internal static partial class AOAFrontEndAPIsModelFactory + { + } +} diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Customizations/Models/ConversionErrorCode.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Customizations/Models/ConversionErrorCode.cs new file mode 100644 index 0000000000000..130061ac374fc --- /dev/null +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Customizations/Models/ConversionErrorCode.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.MixedReality.ObjectAnchors.Conversion +{ + /// The ConversionErrorCode. + [CodeGenModel("ConversionErrorCode")] + public readonly partial struct ConversionErrorCode + { + } +} diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/AOAFrontEndAPIsModelFactory.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/AOAFrontEndAPIsModelFactory.cs index 1045dff23f35b..01f544ba9138f 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/AOAFrontEndAPIsModelFactory.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/AOAFrontEndAPIsModelFactory.cs @@ -6,12 +6,11 @@ #nullable disable using System; -using Azure.MixedReality.ObjectAnchors.Conversion.Models; namespace Azure.MixedReality.ObjectAnchors.Conversion { /// Model factory for read-only models. - public static partial class AOAFrontEndAPIsModelFactory + internal static partial class AOAFrontEndAPIsModelFactory { /// Initializes new instance of AssetConversionProperties class. /// Information about the cause of a ClientError JobStatus. diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/AssetConversionProperties.Serialization.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/AssetConversionProperties.Serialization.cs index 53b8f42f59446..2574cb7678ea9 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/AssetConversionProperties.Serialization.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/AssetConversionProperties.Serialization.cs @@ -8,7 +8,6 @@ using System; using System.Text.Json; using Azure.Core; -using Azure.MixedReality.ObjectAnchors.Conversion.Models; namespace Azure.MixedReality.ObjectAnchors.Conversion { diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/AssetConversionProperties.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/AssetConversionProperties.cs index 8829019a57968..02e8f25b5da38 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/AssetConversionProperties.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/AssetConversionProperties.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using Azure.MixedReality.ObjectAnchors.Conversion.Models; namespace Azure.MixedReality.ObjectAnchors.Conversion { diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/ConversionErrorCode.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/ConversionErrorCode.cs index 4cb718632714f..c935bb4ec2794 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/ConversionErrorCode.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/Generated/Models/ConversionErrorCode.cs @@ -8,7 +8,7 @@ using System; using System.ComponentModel; -namespace Azure.MixedReality.ObjectAnchors.Conversion.Models +namespace Azure.MixedReality.ObjectAnchors.Conversion { /// The ConversionErrorCode. public readonly partial struct ConversionErrorCode : IEquatable diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs index 157596f1b7b80..e0bd17e213fa6 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs @@ -7,6 +7,8 @@ using Azure.Core.Pipeline; using Azure.MixedReality.Authentication; using System.Threading.Tasks; +using System.Collections.Generic; +using System.Linq; namespace Azure.MixedReality.ObjectAnchors.Conversion { @@ -20,6 +22,11 @@ public class ObjectAnchorsConversionClient /// public Guid AccountId { get; } + /// + /// The list of supported asset file types + /// + public IEnumerable SupportedAssetFileTypes { get; } + /// /// The Account Domain to be used by the Client /// @@ -81,6 +88,7 @@ public ObjectAnchorsConversionClient(Guid accountId, string accountDomain, Token Uri serviceEndpoint = options.ServiceEndpoint ?? ConstructObjectAnchorsEndpointUrl(accountDomain); AccountId = accountId; + SupportedAssetFileTypes = options.SupportedAssetFileTypes; _clientDiagnostics = new ClientDiagnostics(options); _pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(mrTokenCredential, GetDefaultScope(serviceEndpoint))); _getBlobUploadEndpointRestClient = new BlobUploadEndpointRestClient(_clientDiagnostics, _pipeline, serviceEndpoint, options.Version); @@ -109,6 +117,11 @@ public virtual AssetConversionOperation StartAssetConversion(AssetConversionOpti scope.Start(); try { + if (!SupportedAssetFileTypes.Contains(options.InputAssetFileType)) + { + throw new UnsupportedAssetFileTypeException(options.InputAssetFileType, SupportedAssetFileTypes); + } + AssetConversionProperties properties = new AssetConversionProperties { InputAssetFileType = options.InputAssetFileType, @@ -138,6 +151,11 @@ public virtual async Task StartAssetConversionAsync(As scope.Start(); try { + if (!SupportedAssetFileTypes.Contains(options.InputAssetFileType)) + { + throw new UnsupportedAssetFileTypeException(options.InputAssetFileType, SupportedAssetFileTypes); + } + AssetConversionProperties properties = new AssetConversionProperties { InputAssetFileType = options.InputAssetFileType, diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs index f93c4d3b0545f..180746664cc12 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs @@ -2,6 +2,8 @@ // Licensed under the MIT License. using System; +using System.Collections; +using System.Collections.Generic; using Azure.Core; using Azure.MixedReality.Authentication; @@ -16,6 +18,11 @@ public class ObjectAnchorsConversionClientOptions : ClientOptions { internal string Version { get; } + /// + /// Gets the list of supported asset file types + /// + public IEnumerable SupportedAssetFileTypes { get; } + /// /// Gets the authentication endpoint. /// @@ -42,6 +49,19 @@ public ObjectAnchorsConversionClientOptions(ServiceVersion version = ServiceVers ServiceVersion.V0_2_preview_0 => "0.2-preview.0", _ => throw new ArgumentException($"The service version {version} is not supported by this library.", nameof(version)) }; + + SupportedAssetFileTypes = version switch + { + ServiceVersion.V0_2_preview_0 => new AssetFileType[] + { + AssetFileType.Fbx, + AssetFileType.Glb, + AssetFileType.Gltf, + AssetFileType.Obj, + AssetFileType.Ply + }, + _ => throw new InvalidOperationException() + }; } /// diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs index f7b6f36e709ae..d28d1e93f6500 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; namespace Azure.MixedReality.ObjectAnchors.Conversion { @@ -10,9 +11,21 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion /// public class UnsupportedAssetFileTypeException : Exception { - internal UnsupportedAssetFileTypeException(AssetFileType assetFileType) - : base($"The provided asset file type of \"{assetFileType}\" is invalid. Supported file types: {string.Join(", ", AssetFileType.validAssetFileTypeValues)}") + internal UnsupportedAssetFileTypeException(AssetFileType assetFileType, IEnumerable supportedAssetFileTypes) + : base($"The provided asset file type of \"{assetFileType}\" is unsupported by Azure Object Anchors for conversion. Supported file types: {string.Join(", ", supportedAssetFileTypes)}") { + AttemptedFileType = assetFileType; + SupportedAssetFileTypes = supportedAssetFileTypes; } + + /// + /// The unsupported filetype provided for asset conversion + /// + public AssetFileType AttemptedFileType { get; } + + /// + /// The list of file types supported by Azure Object Anchors Conversion + /// + public IEnumerable SupportedAssetFileTypes { get; } } } diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/AssetConversionOptionsTests.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/AssetConversionOptionsTests.cs index f331b8b85126f..27f4b2acd671d 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/AssetConversionOptionsTests.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/AssetConversionOptionsTests.cs @@ -40,13 +40,6 @@ public AssetConversionOptionsTests(bool isAsync) : base(isAsync) new object[] { new Vector3(1, 0, 0), default(Uri), false } }; - public static IEnumerable UnsupportedAssetFileTypesFailTestData => - new List - { - new object[] { new AssetFileType(".obj"), true }, - new object[] { new AssetFileType(".exe"), false }, - }; - [Test] [TestCaseSource(nameof(IsNormalizedTestData))] public void NormalizedVectorRequired(Vector3 v, bool expectedSuccess) @@ -81,27 +74,6 @@ public void NullArgumentsFail(Vector3 v, Uri u, bool expectedSuccess) Assert.AreNotEqual(caught, expectedSuccess); } - [Test] - [TestCaseSource(nameof(UnsupportedAssetFileTypesFailTestData))] - public void UnsupportedAssetFileTypesFail(AssetFileType assetFileType, bool expectedSuccess) - { - Vector3 validAssetGravity = new Vector3(1, 0, 0); - AssetLengthUnit assetLengthUnit = AssetLengthUnit.Meters; - bool caught = false; - - try - { - new AssetConversionOptions(new Uri(anyWorkingUriString), assetFileType, validAssetGravity, assetLengthUnit); - } - catch (UnsupportedAssetFileTypeException ex) - { - Console.WriteLine(ex); - caught = true; - } - - Assert.AreNotEqual(caught, expectedSuccess); - } - [Test] public void Vector3StoresValuesCorrectly() { diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs index 64512531b7897..99ffbea3a6cf5 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs @@ -16,6 +16,8 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion.Tests [TestFixture(false)] public class ObjectAnchorsConversionClientTests : ClientTestBase { + private static string anyWorkingUriString = "https://sampleazurestorageurl.com"; + public ObjectAnchorsConversionClientTests(bool isAsync) : base(isAsync) { } @@ -35,6 +37,21 @@ public ObjectAnchorsConversionClientTests(bool isAsync) : base(isAsync) } }; + public static IEnumerable BadFileTypeTestData => + new List + { + new object[] + { + AssetFileType.Obj, + true + }, + new object[] + { + new AssetFileType(".exe"), + false + }, + }; + [Test] [TestCaseSource(nameof(BadClientArgumentsTestData))] public void BadClientArguments(Guid accountId, string accountDomain, AccessToken credential, bool shouldSucceed) @@ -51,5 +68,27 @@ public void BadClientArguments(Guid accountId, string accountDomain, AccessToken Assert.AreNotEqual(shouldSucceed, excepted); } + + [Test] + [TestCaseSource(nameof(BadFileTypeTestData))] + public async Task BadFileType(AssetFileType ft, bool passes) + { + bool exceptedWithUnsupportedFileType = !passes; + try + { + ObjectAnchorsConversionClient client = new ObjectAnchorsConversionClient(Guid.NewGuid(), "eastus2.azure.com", new AccessToken("dummykey", new DateTimeOffset(new DateTime(3000, 1, 1)))); + await client.StartAssetConversionAsync(new AssetConversionOptions(new Uri(anyWorkingUriString), new AssetFileType(".exe"), new AssetConversionConfiguration(new System.Numerics.Vector3(0, 0, 1), 1))); + } + catch (UnsupportedAssetFileTypeException) + { + exceptedWithUnsupportedFileType = true; + } + catch (Exception) + { + // This is fine + } + + Assert.True(exceptedWithUnsupportedFileType); + } } } From b6fac9838b06e20511c8fb56c6cc36f71dbf513a Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Thu, 17 Jun 2021 14:47:31 -0700 Subject: [PATCH 04/14] Updated API --- ...ObjectAnchors.Conversion.netstandard2.0.cs | 77 +++++++++---------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs index 905cfd1d81717..4c1035568ac49 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs @@ -1,10 +1,5 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion { - public static partial class AOAFrontEndAPIsModelFactory - { - public static Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionProperties AssetConversionProperties(string clientErrorDetails = null, string serverErrorDetails = null, Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode errorCode = default(Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode), System.Guid? jobIdInternal = default(System.Guid?), string outputModelUriString = null, Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionStatus? conversionStatus = default(Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionStatus?), string assetFileTypeString = null, string inputAssetUriString = null, System.Guid? accountIdInternal = default(System.Guid?), Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionConfiguration conversionConfiguration = null) { throw null; } - public static Azure.MixedReality.ObjectAnchors.Conversion.AssetUploadUriResult AssetUploadUriResult(string uploadUriString = null) { throw null; } - } public partial class AssetConversionConfiguration { internal AssetConversionConfiguration() { } @@ -50,7 +45,7 @@ internal AssetConversionProperties() { } public string ClientErrorDetails { get { throw null; } } public Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionConfiguration ConversionConfiguration { get { throw null; } } public Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionStatus? ConversionStatus { get { throw null; } } - public Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode ErrorCode { get { throw null; } } + public Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode ErrorCode { get { throw null; } } public Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType InputAssetFileType { get { throw null; } } public System.Uri InputAssetUri { get { throw null; } } public System.Guid JobId { get { throw null; } set { } } @@ -76,7 +71,6 @@ public enum AssetConversionStatus public static Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType Gltf { get { throw null; } } public static Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType Obj { get { throw null; } } public static Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType Ply { get { throw null; } } - public static System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } public bool Equals(Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType other) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override bool Equals(object obj) { throw null; } @@ -103,6 +97,36 @@ public partial class AssetUploadUriResult internal AssetUploadUriResult() { } public System.Uri UploadUri { get { throw null; } } } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ConversionErrorCode : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ConversionErrorCode(string value) { throw null; } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode AssetCannotBeConverted { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode AssetDimensionsOutOfBounds { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode AssetSizeTooLarge { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode InvalidAssetUri { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode InvalidFaceVertices { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode InvalidGravity { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode InvalidJobId { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode InvalidScale { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode NoError { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode ServiceError { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode TooManyRigPoses { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode Unknown { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode ZeroFaces { get { throw null; } } + public static Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode ZeroTrajectoriesGenerated { get { throw null; } } + public bool Equals(Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode left, Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode right) { throw null; } + public static implicit operator Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode (string value) { throw null; } + public static bool operator !=(Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode left, Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode right) { throw null; } + public override string ToString() { throw null; } + } public partial class ObjectAnchorsConversionClient { protected ObjectAnchorsConversionClient() { } @@ -112,6 +136,7 @@ public ObjectAnchorsConversionClient(System.Guid accountId, string accountDomain public ObjectAnchorsConversionClient(System.Guid accountId, string accountDomain, Azure.Core.TokenCredential credential, Azure.MixedReality.ObjectAnchors.Conversion.ObjectAnchorsConversionClientOptions options = null) { } public string AccountDomain { get { throw null; } } public System.Guid AccountId { get { throw null; } } + public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } public virtual Azure.Response GetAssetUploadUri(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAssetUploadUriAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionOperation StartAssetConversion(Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } @@ -123,6 +148,7 @@ public ObjectAnchorsConversionClientOptions(Azure.MixedReality.ObjectAnchors.Con public System.Uri MixedRealityAuthenticationEndpoint { get { throw null; } set { } } public Azure.MixedReality.Authentication.MixedRealityStsClientOptions MixedRealityAuthenticationOptions { get { throw null; } set { } } public System.Uri ServiceEndpoint { get { throw null; } set { } } + public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } public enum ServiceVersion { V0_2_preview_0 = 1, @@ -131,7 +157,7 @@ public enum ServiceVersion public static partial class ObjectAnchorsConversionModelFactory { public static Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionConfiguration AssetConversionConfiguration(System.Numerics.Vector3 assetDimensions, System.Numerics.Vector3 boundingBoxCenter, System.Numerics.Vector3 gravity, System.Collections.Generic.IReadOnlyList keyFrameIndexes, System.Collections.Generic.IReadOnlyList groundTruthTrajectoryCameraPoses, System.Numerics.Quaternion principalAxis, float scale, System.Numerics.Vector4 supportingPlane, System.Collections.Generic.IReadOnlyList testTrajectoryCameraPoses) { throw null; } - public static Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionProperties AssetConversionProperties(string clientErrorDetails, string serverErrorDetails, Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode conversionErrorCode, System.Guid? jobId, System.Uri outputModelUri, Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionStatus? assetConversionStatus, Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType assetFileType, System.Uri uploadedInputAssetUri, System.Guid? accountId, Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionConfiguration assetConversionConfiguration) { throw null; } + public static Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionProperties AssetConversionProperties(string clientErrorDetails, string serverErrorDetails, Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode conversionErrorCode, System.Guid? jobId, System.Uri outputModelUri, Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionStatus? assetConversionStatus, Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType assetFileType, System.Uri uploadedInputAssetUri, System.Guid? accountId, Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionConfiguration assetConversionConfiguration) { throw null; } public static Azure.MixedReality.ObjectAnchors.Conversion.AssetUploadUriResult GetAssetUploadUriResult(System.Uri uploadedInputAssetUri) { throw null; } public static Azure.MixedReality.ObjectAnchors.Conversion.TrajectoryPose TrajectoryPose(System.Numerics.Quaternion rotation, System.Numerics.Vector3 translation) { throw null; } } @@ -151,38 +177,7 @@ public static partial class ObjectAnchorsConversionModelFactory public partial class UnsupportedAssetFileTypeException : System.Exception { internal UnsupportedAssetFileTypeException() { } - } -} -namespace Azure.MixedReality.ObjectAnchors.Conversion.Models -{ - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct ConversionErrorCode : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public ConversionErrorCode(string value) { throw null; } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode AssetCannotBeConverted { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode AssetDimensionsOutOfBounds { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode AssetSizeTooLarge { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode InvalidAssetUri { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode InvalidFaceVertices { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode InvalidGravity { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode InvalidJobId { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode InvalidScale { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode NoError { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode ServiceError { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode TooManyRigPoses { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode Unknown { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode ZeroFaces { get { throw null; } } - public static Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode ZeroTrajectoriesGenerated { get { throw null; } } - public bool Equals(Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode left, Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode right) { throw null; } - public static implicit operator Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode (string value) { throw null; } - public static bool operator !=(Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode left, Azure.MixedReality.ObjectAnchors.Conversion.Models.ConversionErrorCode right) { throw null; } - public override string ToString() { throw null; } + public Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType AttemptedFileType { get { throw null; } } + public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } } } From be31b541bdff70485103b4c9a122dcdada4d548a Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Fri, 18 Jun 2021 14:10:00 -0700 Subject: [PATCH 05/14] Added public exception constructors --- .../ObjectAnchorsConversionClientOptions.cs | 2 +- .../src/UnsupportedAssetFileTypeException.cs | 40 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs index 180746664cc12..0f4eb49d4dd01 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs @@ -21,7 +21,7 @@ public class ObjectAnchorsConversionClientOptions : ClientOptions /// /// Gets the list of supported asset file types /// - public IEnumerable SupportedAssetFileTypes { get; } + internal IEnumerable SupportedAssetFileTypes { get; } /// /// Gets the authentication endpoint. diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs index d28d1e93f6500..ef26f0f227a33 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs @@ -3,14 +3,42 @@ using System; using System.Collections.Generic; +using System.Runtime.Serialization; namespace Azure.MixedReality.ObjectAnchors.Conversion { /// /// An Exception thrown durin an attempt to provide an unsupported asset file type in an asset conversion operation /// - public class UnsupportedAssetFileTypeException : Exception + public class UnsupportedAssetFileTypeException : Exception, ISerializable { + /// + /// Creates an instance of the UnsupportedAssetFileTypeException + /// + public UnsupportedAssetFileTypeException() + : base($"The provided asset file type is unsupported by Azure Object Anchors for conversion.") + { + } + + /// + /// Creates an instance of the UnsupportedAssetFileTypeException + /// + /// The message corresponding to the exception + public UnsupportedAssetFileTypeException(string message) + : base(message) + { + } + + /// + /// An Exception thrown durin an attempt to provide an unsupported asset file type in an asset conversion operation + /// + /// The message corresponding to the exception + /// The inner exception + public UnsupportedAssetFileTypeException(string message, Exception inner) + : base(message, inner) + { + } + internal UnsupportedAssetFileTypeException(AssetFileType assetFileType, IEnumerable supportedAssetFileTypes) : base($"The provided asset file type of \"{assetFileType}\" is unsupported by Azure Object Anchors for conversion. Supported file types: {string.Join(", ", supportedAssetFileTypes)}") { @@ -18,6 +46,16 @@ internal UnsupportedAssetFileTypeException(AssetFileType assetFileType, IEnumera SupportedAssetFileTypes = supportedAssetFileTypes; } + /// + /// An Exception thrown during an attempt to provide an unsupported asset file type in an asset conversion operation + /// + /// The SerializationInfo + /// The StreamingContext + protected UnsupportedAssetFileTypeException(SerializationInfo info, StreamingContext context) + : base(info, context) + { + } + /// /// The unsupported filetype provided for asset conversion /// From 4d262ecae59fccd06ad61591b2ce889b295e94a1 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Fri, 18 Jun 2021 14:51:42 -0700 Subject: [PATCH 06/14] Recreate API --- ...ixedReality.ObjectAnchors.Conversion.netstandard2.0.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs index 4c1035568ac49..ebead32e3de4e 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs @@ -148,7 +148,6 @@ public ObjectAnchorsConversionClientOptions(Azure.MixedReality.ObjectAnchors.Con public System.Uri MixedRealityAuthenticationEndpoint { get { throw null; } set { } } public Azure.MixedReality.Authentication.MixedRealityStsClientOptions MixedRealityAuthenticationOptions { get { throw null; } set { } } public System.Uri ServiceEndpoint { get { throw null; } set { } } - public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } public enum ServiceVersion { V0_2_preview_0 = 1, @@ -174,9 +173,12 @@ public static partial class ObjectAnchorsConversionModelFactory [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override int GetHashCode() { throw null; } } - public partial class UnsupportedAssetFileTypeException : System.Exception + public partial class UnsupportedAssetFileTypeException : System.Exception, System.Runtime.Serialization.ISerializable { - internal UnsupportedAssetFileTypeException() { } + public UnsupportedAssetFileTypeException() { } + protected UnsupportedAssetFileTypeException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public UnsupportedAssetFileTypeException(string message) { } + public UnsupportedAssetFileTypeException(string message, System.Exception inner) { } public Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType AttemptedFileType { get { throw null; } } public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } } From eaa26863f6aa0c21f37831e1c750ceba861dcd47 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Mon, 21 Jun 2021 13:33:20 -0700 Subject: [PATCH 07/14] Renamed exception --- ....ObjectAnchors.Conversion.netstandard2.0.cs | 18 +++++++++--------- ...s => NotSupportedAssetFileTypeException.cs} | 12 ++++++------ .../src/ObjectAnchorsConversionClient.cs | 4 ++-- .../ObjectAnchorsConversionClientTests.cs | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) rename sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/{UnsupportedAssetFileTypeException.cs => NotSupportedAssetFileTypeException.cs} (81%) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs index ebead32e3de4e..231de272491ef 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs @@ -127,6 +127,15 @@ internal AssetUploadUriResult() { } public static bool operator !=(Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode left, Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode right) { throw null; } public override string ToString() { throw null; } } + public partial class NotSupportedAssetFileTypeException : System.Exception, System.Runtime.Serialization.ISerializable + { + public NotSupportedAssetFileTypeException() { } + protected NotSupportedAssetFileTypeException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public NotSupportedAssetFileTypeException(string message) { } + public NotSupportedAssetFileTypeException(string message, System.Exception inner) { } + public Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType AttemptedFileType { get { throw null; } } + public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } + } public partial class ObjectAnchorsConversionClient { protected ObjectAnchorsConversionClient() { } @@ -173,13 +182,4 @@ public static partial class ObjectAnchorsConversionModelFactory [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override int GetHashCode() { throw null; } } - public partial class UnsupportedAssetFileTypeException : System.Exception, System.Runtime.Serialization.ISerializable - { - public UnsupportedAssetFileTypeException() { } - protected UnsupportedAssetFileTypeException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - public UnsupportedAssetFileTypeException(string message) { } - public UnsupportedAssetFileTypeException(string message, System.Exception inner) { } - public Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType AttemptedFileType { get { throw null; } } - public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } - } } diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs similarity index 81% rename from sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs rename to sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs index ef26f0f227a33..9c4325255515b 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/UnsupportedAssetFileTypeException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs @@ -10,12 +10,12 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion /// /// An Exception thrown durin an attempt to provide an unsupported asset file type in an asset conversion operation /// - public class UnsupportedAssetFileTypeException : Exception, ISerializable + public class NotSupportedAssetFileTypeException : Exception, ISerializable { /// /// Creates an instance of the UnsupportedAssetFileTypeException /// - public UnsupportedAssetFileTypeException() + public NotSupportedAssetFileTypeException() : base($"The provided asset file type is unsupported by Azure Object Anchors for conversion.") { } @@ -24,7 +24,7 @@ public UnsupportedAssetFileTypeException() /// Creates an instance of the UnsupportedAssetFileTypeException /// /// The message corresponding to the exception - public UnsupportedAssetFileTypeException(string message) + public NotSupportedAssetFileTypeException(string message) : base(message) { } @@ -34,12 +34,12 @@ public UnsupportedAssetFileTypeException(string message) /// /// The message corresponding to the exception /// The inner exception - public UnsupportedAssetFileTypeException(string message, Exception inner) + public NotSupportedAssetFileTypeException(string message, Exception inner) : base(message, inner) { } - internal UnsupportedAssetFileTypeException(AssetFileType assetFileType, IEnumerable supportedAssetFileTypes) + internal NotSupportedAssetFileTypeException(AssetFileType assetFileType, IEnumerable supportedAssetFileTypes) : base($"The provided asset file type of \"{assetFileType}\" is unsupported by Azure Object Anchors for conversion. Supported file types: {string.Join(", ", supportedAssetFileTypes)}") { AttemptedFileType = assetFileType; @@ -51,7 +51,7 @@ internal UnsupportedAssetFileTypeException(AssetFileType assetFileType, IEnumera /// /// The SerializationInfo /// The StreamingContext - protected UnsupportedAssetFileTypeException(SerializationInfo info, StreamingContext context) + protected NotSupportedAssetFileTypeException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs index e0bd17e213fa6..fe1793afdaf42 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs @@ -119,7 +119,7 @@ public virtual AssetConversionOperation StartAssetConversion(AssetConversionOpti { if (!SupportedAssetFileTypes.Contains(options.InputAssetFileType)) { - throw new UnsupportedAssetFileTypeException(options.InputAssetFileType, SupportedAssetFileTypes); + throw new NotSupportedAssetFileTypeException(options.InputAssetFileType, SupportedAssetFileTypes); } AssetConversionProperties properties = new AssetConversionProperties @@ -153,7 +153,7 @@ public virtual async Task StartAssetConversionAsync(As { if (!SupportedAssetFileTypes.Contains(options.InputAssetFileType)) { - throw new UnsupportedAssetFileTypeException(options.InputAssetFileType, SupportedAssetFileTypes); + throw new NotSupportedAssetFileTypeException(options.InputAssetFileType, SupportedAssetFileTypes); } AssetConversionProperties properties = new AssetConversionProperties diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs index 99ffbea3a6cf5..524ede3d5aefa 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs @@ -79,7 +79,7 @@ public async Task BadFileType(AssetFileType ft, bool passes) ObjectAnchorsConversionClient client = new ObjectAnchorsConversionClient(Guid.NewGuid(), "eastus2.azure.com", new AccessToken("dummykey", new DateTimeOffset(new DateTime(3000, 1, 1)))); await client.StartAssetConversionAsync(new AssetConversionOptions(new Uri(anyWorkingUriString), new AssetFileType(".exe"), new AssetConversionConfiguration(new System.Numerics.Vector3(0, 0, 1), 1))); } - catch (UnsupportedAssetFileTypeException) + catch (NotSupportedAssetFileTypeException) { exceptedWithUnsupportedFileType = true; } From f312f1f7e34bb9531f4d332e194c9416e0710140 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Mon, 21 Jun 2021 13:41:53 -0700 Subject: [PATCH 08/14] Fix typos --- .../src/NotSupportedAssetFileTypeException.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs index 9c4325255515b..24fee7100b2d4 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs @@ -8,7 +8,7 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion { /// - /// An Exception thrown durin an attempt to provide an unsupported asset file type in an asset conversion operation + /// An Exception thrown during an attempt to provide an unsupported asset file type in an asset conversion operation /// public class NotSupportedAssetFileTypeException : Exception, ISerializable { @@ -30,7 +30,7 @@ public NotSupportedAssetFileTypeException(string message) } /// - /// An Exception thrown durin an attempt to provide an unsupported asset file type in an asset conversion operation + /// An Exception thrown during an attempt to provide an unsupported asset file type in an asset conversion operation /// /// The message corresponding to the exception /// The inner exception From a5ffc33642c802fbbb02b7bcdab8170607889def Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Mon, 21 Jun 2021 16:25:36 -0700 Subject: [PATCH 09/14] Switched to readonlylist, removed unneeded usings --- .../src/AssetFileType.cs | 2 -- .../src/NotSupportedAssetFileTypeException.cs | 2 +- .../src/ObjectAnchorsConversionClient.cs | 6 ++++-- .../src/ObjectAnchorsConversionClientOptions.cs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs index a7e6d4a1650e2..7f2d55365ecb2 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileType.cs @@ -2,10 +2,8 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; using System.ComponentModel; using System.IO; -using System.Linq; namespace Azure.MixedReality.ObjectAnchors.Conversion { diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs index 24fee7100b2d4..56802979c86f8 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs @@ -64,6 +64,6 @@ protected NotSupportedAssetFileTypeException(SerializationInfo info, StreamingCo /// /// The list of file types supported by Azure Object Anchors Conversion /// - public IEnumerable SupportedAssetFileTypes { get; } + public IReadOnlyList SupportedAssetFileTypes { get; } } } diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs index fe1793afdaf42..585f9913954ce 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs @@ -25,7 +25,9 @@ public class ObjectAnchorsConversionClient /// /// The list of supported asset file types /// - public IEnumerable SupportedAssetFileTypes { get; } + public IReadOnlyList SupportedAssetFileTypes { get { return SupportedAssetFileTypesSet.ToList(); } } + + internal HashSet SupportedAssetFileTypesSet { get; } /// /// The Account Domain to be used by the Client @@ -88,7 +90,7 @@ public ObjectAnchorsConversionClient(Guid accountId, string accountDomain, Token Uri serviceEndpoint = options.ServiceEndpoint ?? ConstructObjectAnchorsEndpointUrl(accountDomain); AccountId = accountId; - SupportedAssetFileTypes = options.SupportedAssetFileTypes; + SupportedAssetFileTypesSet = options.SupportedAssetFileTypes; _clientDiagnostics = new ClientDiagnostics(options); _pipeline = HttpPipelineBuilder.Build(options, new BearerTokenAuthenticationPolicy(mrTokenCredential, GetDefaultScope(serviceEndpoint))); _getBlobUploadEndpointRestClient = new BlobUploadEndpointRestClient(_clientDiagnostics, _pipeline, serviceEndpoint, options.Version); diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs index 0f4eb49d4dd01..4c181b70ebcfc 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClientOptions.cs @@ -21,7 +21,7 @@ public class ObjectAnchorsConversionClientOptions : ClientOptions /// /// Gets the list of supported asset file types /// - internal IEnumerable SupportedAssetFileTypes { get; } + internal HashSet SupportedAssetFileTypes { get; } /// /// Gets the authentication endpoint. @@ -52,7 +52,7 @@ public ObjectAnchorsConversionClientOptions(ServiceVersion version = ServiceVers SupportedAssetFileTypes = version switch { - ServiceVersion.V0_2_preview_0 => new AssetFileType[] + ServiceVersion.V0_2_preview_0 => new HashSet { AssetFileType.Fbx, AssetFileType.Glb, From 92f6a223fab6a6284e44a5b89359baea50734288 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Mon, 21 Jun 2021 17:20:39 -0700 Subject: [PATCH 10/14] Renamed exception --- ...ObjectAnchors.Conversion.netstandard2.0.cs | 20 +++++++++---------- ... => AssetFileTypeNotSupportedException.cs} | 12 +++++------ .../src/ObjectAnchorsConversionClient.cs | 4 ++-- .../ObjectAnchorsConversionClientTests.cs | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) rename sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/{NotSupportedAssetFileTypeException.cs => AssetFileTypeNotSupportedException.cs} (84%) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs index 231de272491ef..629af6d1a93cb 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs @@ -81,6 +81,15 @@ public enum AssetConversionStatus public static bool operator !=(Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType left, Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType right) { throw null; } public override string ToString() { throw null; } } + public partial class AssetFileTypeNotSupportedException : System.Exception, System.Runtime.Serialization.ISerializable + { + public AssetFileTypeNotSupportedException() { } + protected AssetFileTypeNotSupportedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public AssetFileTypeNotSupportedException(string message) { } + public AssetFileTypeNotSupportedException(string message, System.Exception inner) { } + public Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType AttemptedFileType { get { throw null; } } + public System.Collections.Generic.IReadOnlyList SupportedAssetFileTypes { get { throw null; } } + } public enum AssetLengthUnit { Meters = 0, @@ -127,15 +136,6 @@ internal AssetUploadUriResult() { } public static bool operator !=(Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode left, Azure.MixedReality.ObjectAnchors.Conversion.ConversionErrorCode right) { throw null; } public override string ToString() { throw null; } } - public partial class NotSupportedAssetFileTypeException : System.Exception, System.Runtime.Serialization.ISerializable - { - public NotSupportedAssetFileTypeException() { } - protected NotSupportedAssetFileTypeException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } - public NotSupportedAssetFileTypeException(string message) { } - public NotSupportedAssetFileTypeException(string message, System.Exception inner) { } - public Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType AttemptedFileType { get { throw null; } } - public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } - } public partial class ObjectAnchorsConversionClient { protected ObjectAnchorsConversionClient() { } @@ -145,7 +145,7 @@ public ObjectAnchorsConversionClient(System.Guid accountId, string accountDomain public ObjectAnchorsConversionClient(System.Guid accountId, string accountDomain, Azure.Core.TokenCredential credential, Azure.MixedReality.ObjectAnchors.Conversion.ObjectAnchorsConversionClientOptions options = null) { } public string AccountDomain { get { throw null; } } public System.Guid AccountId { get { throw null; } } - public System.Collections.Generic.IEnumerable SupportedAssetFileTypes { get { throw null; } } + public System.Collections.Generic.IReadOnlyList SupportedAssetFileTypes { get { throw null; } } public virtual Azure.Response GetAssetUploadUri(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task> GetAssetUploadUriAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionOperation StartAssetConversion(Azure.MixedReality.ObjectAnchors.Conversion.AssetConversionOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs similarity index 84% rename from sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs rename to sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs index 56802979c86f8..93affe9e85c0e 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/NotSupportedAssetFileTypeException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs @@ -10,12 +10,12 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion /// /// An Exception thrown during an attempt to provide an unsupported asset file type in an asset conversion operation /// - public class NotSupportedAssetFileTypeException : Exception, ISerializable + public class AssetFileTypeNotSupportedException : Exception, ISerializable { /// /// Creates an instance of the UnsupportedAssetFileTypeException /// - public NotSupportedAssetFileTypeException() + public AssetFileTypeNotSupportedException() : base($"The provided asset file type is unsupported by Azure Object Anchors for conversion.") { } @@ -24,7 +24,7 @@ public NotSupportedAssetFileTypeException() /// Creates an instance of the UnsupportedAssetFileTypeException /// /// The message corresponding to the exception - public NotSupportedAssetFileTypeException(string message) + public AssetFileTypeNotSupportedException(string message) : base(message) { } @@ -34,12 +34,12 @@ public NotSupportedAssetFileTypeException(string message) /// /// The message corresponding to the exception /// The inner exception - public NotSupportedAssetFileTypeException(string message, Exception inner) + public AssetFileTypeNotSupportedException(string message, Exception inner) : base(message, inner) { } - internal NotSupportedAssetFileTypeException(AssetFileType assetFileType, IEnumerable supportedAssetFileTypes) + internal AssetFileTypeNotSupportedException(AssetFileType assetFileType, IReadOnlyList supportedAssetFileTypes) : base($"The provided asset file type of \"{assetFileType}\" is unsupported by Azure Object Anchors for conversion. Supported file types: {string.Join(", ", supportedAssetFileTypes)}") { AttemptedFileType = assetFileType; @@ -51,7 +51,7 @@ internal NotSupportedAssetFileTypeException(AssetFileType assetFileType, IEnumer /// /// The SerializationInfo /// The StreamingContext - protected NotSupportedAssetFileTypeException(SerializationInfo info, StreamingContext context) + protected AssetFileTypeNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs index 585f9913954ce..df2e94d0595c4 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs @@ -121,7 +121,7 @@ public virtual AssetConversionOperation StartAssetConversion(AssetConversionOpti { if (!SupportedAssetFileTypes.Contains(options.InputAssetFileType)) { - throw new NotSupportedAssetFileTypeException(options.InputAssetFileType, SupportedAssetFileTypes); + throw new AssetFileTypeNotSupportedException(options.InputAssetFileType, SupportedAssetFileTypes); } AssetConversionProperties properties = new AssetConversionProperties @@ -155,7 +155,7 @@ public virtual async Task StartAssetConversionAsync(As { if (!SupportedAssetFileTypes.Contains(options.InputAssetFileType)) { - throw new NotSupportedAssetFileTypeException(options.InputAssetFileType, SupportedAssetFileTypes); + throw new AssetFileTypeNotSupportedException(options.InputAssetFileType, SupportedAssetFileTypes); } AssetConversionProperties properties = new AssetConversionProperties diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs index 524ede3d5aefa..3ebc25ad98aae 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/tests/ObjectAnchorsConversionClientTests.cs @@ -79,7 +79,7 @@ public async Task BadFileType(AssetFileType ft, bool passes) ObjectAnchorsConversionClient client = new ObjectAnchorsConversionClient(Guid.NewGuid(), "eastus2.azure.com", new AccessToken("dummykey", new DateTimeOffset(new DateTime(3000, 1, 1)))); await client.StartAssetConversionAsync(new AssetConversionOptions(new Uri(anyWorkingUriString), new AssetFileType(".exe"), new AssetConversionConfiguration(new System.Numerics.Vector3(0, 0, 1), 1))); } - catch (NotSupportedAssetFileTypeException) + catch (AssetFileTypeNotSupportedException) { exceptedWithUnsupportedFileType = true; } From e60771c8b3433c0552f18ee1a9f23d014d722ec9 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Tue, 22 Jun 2021 09:49:43 -0700 Subject: [PATCH 11/14] Addressed PR comments regarding exception --- ...ObjectAnchors.Conversion.netstandard2.0.cs | 1 + .../src/AssetFileTypeNotSupportedException.cs | 20 +++++++++++++------ .../src/ObjectAnchorsConversionClient.cs | 16 +++++++++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs index 629af6d1a93cb..f2e216bd70c24 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/api/Azure.MixedReality.ObjectAnchors.Conversion.netstandard2.0.cs @@ -89,6 +89,7 @@ public AssetFileTypeNotSupportedException(string message) { } public AssetFileTypeNotSupportedException(string message, System.Exception inner) { } public Azure.MixedReality.ObjectAnchors.Conversion.AssetFileType AttemptedFileType { get { throw null; } } public System.Collections.Generic.IReadOnlyList SupportedAssetFileTypes { get { throw null; } } + public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } } public enum AssetLengthUnit { diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs index 93affe9e85c0e..ef7b1e84a86b2 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Runtime.Serialization; +using Azure.Core; namespace Azure.MixedReality.ObjectAnchors.Conversion { @@ -13,7 +14,7 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion public class AssetFileTypeNotSupportedException : Exception, ISerializable { /// - /// Creates an instance of the UnsupportedAssetFileTypeException + /// Creates an instance of the /// public AssetFileTypeNotSupportedException() : base($"The provided asset file type is unsupported by Azure Object Anchors for conversion.") @@ -39,6 +40,17 @@ public AssetFileTypeNotSupportedException(string message, Exception inner) { } + /// + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { + Argument.AssertNotNull(info, nameof(info)); + + info.AddValue(nameof(AttemptedFileType), AttemptedFileType); + info.AddValue(nameof(SupportedAssetFileTypes), SupportedAssetFileTypes); + + base.GetObjectData(info, context); + } + internal AssetFileTypeNotSupportedException(AssetFileType assetFileType, IReadOnlyList supportedAssetFileTypes) : base($"The provided asset file type of \"{assetFileType}\" is unsupported by Azure Object Anchors for conversion. Supported file types: {string.Join(", ", supportedAssetFileTypes)}") { @@ -46,11 +58,7 @@ internal AssetFileTypeNotSupportedException(AssetFileType assetFileType, IReadOn SupportedAssetFileTypes = supportedAssetFileTypes; } - /// - /// An Exception thrown during an attempt to provide an unsupported asset file type in an asset conversion operation - /// - /// The SerializationInfo - /// The StreamingContext + /// protected AssetFileTypeNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs index df2e94d0595c4..eda0080d715a5 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs @@ -17,6 +17,7 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion /// public class ObjectAnchorsConversionClient { + private HashSet _supportedAssetFileTypesSet; /// /// The Account ID to be used by the Client /// @@ -25,9 +26,20 @@ public class ObjectAnchorsConversionClient /// /// The list of supported asset file types /// - public IReadOnlyList SupportedAssetFileTypes { get { return SupportedAssetFileTypesSet.ToList(); } } + public IReadOnlyList SupportedAssetFileTypes { get; private set; } - internal HashSet SupportedAssetFileTypesSet { get; } + internal HashSet SupportedAssetFileTypesSet + { + get + { + return _supportedAssetFileTypesSet; + } + set + { + _supportedAssetFileTypesSet = value; + SupportedAssetFileTypes = value.ToList(); + } + } /// /// The Account Domain to be used by the Client From af314dd111099005824117ce51fc353e50ac47c4 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Tue, 22 Jun 2021 09:56:47 -0700 Subject: [PATCH 12/14] Fixed nits --- .../src/AssetFileTypeNotSupportedException.cs | 6 +++++- .../src/ObjectAnchorsConversionClient.cs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs index ef7b1e84a86b2..81bf2b50a482a 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs @@ -58,7 +58,11 @@ internal AssetFileTypeNotSupportedException(AssetFileType assetFileType, IReadOn SupportedAssetFileTypes = supportedAssetFileTypes; } - /// + /// + /// An Exception thrown during an attempt to provide an unsupported asset file type in an asset conversion operation + /// + /// The SerializationInfo + /// The StreamingContext protected AssetFileTypeNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs index eda0080d715a5..b48c603a34608 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/ObjectAnchorsConversionClient.cs @@ -18,6 +18,7 @@ namespace Azure.MixedReality.ObjectAnchors.Conversion public class ObjectAnchorsConversionClient { private HashSet _supportedAssetFileTypesSet; + /// /// The Account ID to be used by the Client /// From 5ccb7b15a38c1e04500d3a9d0095fd31060b39f1 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Tue, 22 Jun 2021 10:03:02 -0700 Subject: [PATCH 13/14] Fixed documentation for exception --- .../src/AssetFileTypeNotSupportedException.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs index 81bf2b50a482a..dc481c5f9b608 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs @@ -22,7 +22,7 @@ public AssetFileTypeNotSupportedException() } /// - /// Creates an instance of the UnsupportedAssetFileTypeException + /// Creates an instance of the /// /// The message corresponding to the exception public AssetFileTypeNotSupportedException(string message) @@ -31,7 +31,7 @@ public AssetFileTypeNotSupportedException(string message) } /// - /// An Exception thrown during an attempt to provide an unsupported asset file type in an asset conversion operation + /// Creates an Exception thrown during an attempt to provide an unsupported asset file type in an asset conversion operation /// /// The message corresponding to the exception /// The inner exception From 3944a461de8eea18033be46dd3c61c15415e3df8 Mon Sep 17 00:00:00 2001 From: Jacob Stenzel Date: Tue, 22 Jun 2021 11:39:11 -0700 Subject: [PATCH 14/14] Fixed constructor based on serialization --- .../src/AssetFileTypeNotSupportedException.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs index dc481c5f9b608..b441b7baa6c3c 100644 --- a/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs +++ b/sdk/objectanchors/Azure.MixedReality.ObjectAnchors.Conversion/src/AssetFileTypeNotSupportedException.cs @@ -66,6 +66,8 @@ internal AssetFileTypeNotSupportedException(AssetFileType assetFileType, IReadOn protected AssetFileTypeNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { + AttemptedFileType = (AssetFileType) info.GetValue(nameof(AttemptedFileType), typeof(AssetFileType)); + SupportedAssetFileTypes = (IReadOnlyList) info.GetValue(nameof(SupportedAssetFileTypes), typeof(IReadOnlyList)); } ///