Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from xpouyat/dev
Browse files Browse the repository at this point in the history
Add support for .Net Framework 4.8
  • Loading branch information
xpouyat authored Nov 20, 2023
2 parents b8dace5 + 3b9ed80 commit a1ddbed
Show file tree
Hide file tree
Showing 28 changed files with 377 additions and 65 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,5 @@ MigrationBackup/

# Fody - auto-generated XML schema
FodyWeavers.xsd
/Sample/appsettings.json
/SampleNet7.0/appsettings.json
/SampleNetFramework4.8/appsettings.json
11 changes: 10 additions & 1 deletion MK.IO.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ VisualStudioVersion = 17.7.34018.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MK.IO", "MK.IO\MK.IO.csproj", "{D49EB09F-BB45-446F-8CC6-29E1C6E73EFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{AC8541CD-7314-4B58-BA18-483891137232}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleNet7.0", "SampleNet7.0\SampleNet7.0.csproj", "{AC8541CD-7314-4B58-BA18-483891137232}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleNetFramework4.8", "SampleNetFramework4.8\SampleNetFramework4.8.csproj", "{FD73FD43-77EF-4057-B13D-98FC72F8F2C7}"
ProjectSection(ProjectDependencies) = postProject
{D49EB09F-BB45-446F-8CC6-29E1C6E73EFB} = {D49EB09F-BB45-446F-8CC6-29E1C6E73EFB}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,6 +26,10 @@ Global
{AC8541CD-7314-4B58-BA18-483891137232}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC8541CD-7314-4B58-BA18-483891137232}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC8541CD-7314-4B58-BA18-483891137232}.Release|Any CPU.Build.0 = Release|Any CPU
{FD73FD43-77EF-4057-B13D-98FC72F8F2C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD73FD43-77EF-4057-B13D-98FC72F8F2C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD73FD43-77EF-4057-B13D-98FC72F8F2C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD73FD43-77EF-4057-B13D-98FC72F8F2C7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 3 additions & 0 deletions MK.IO/AccountFilter/AccountFiltersOperations.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using MK.IO.Models;
using Newtonsoft.Json;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO.Asset
{
Expand Down
11 changes: 7 additions & 4 deletions MK.IO/Asset/AssetsOperations.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using MK.IO.Models;
using Newtonsoft.Json;
using System.Web;
using System.Net;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO.Asset
{
Expand Down Expand Up @@ -69,7 +72,7 @@ public async Task<PagedResult<AssetSchema>> ListAsPageAsync(string? orderBy = nu

return new PagedResult<AssetSchema>
{
NextPageLink = HttpUtility.UrlDecode(nextPageLink),
NextPageLink = WebUtility.UrlDecode(nextPageLink),
Results = JsonConvert.DeserializeObject<AssetListResponseSchema>(responseContent, ConverterLE.Settings).Value
};
}
Expand All @@ -93,7 +96,7 @@ public async Task<PagedResult<AssetSchema>> ListAsPageNextAsync(string? nextPage

return new PagedResult<AssetSchema>
{
NextPageLink = HttpUtility.UrlDecode(nextPageLink),
NextPageLink = WebUtility.UrlDecode(nextPageLink),
Results = JsonConvert.DeserializeObject<AssetListResponseSchema>(responseContent, ConverterLE.Settings).Value
};
}
Expand Down Expand Up @@ -186,7 +189,7 @@ public AssetStorageResponseSchema ListTracksAndDirListing(string assetName)
public async Task<AssetStorageResponseSchema> ListTracksAndDirListingAsync(string assetName)
{
Argument.AssertNotNullOrEmpty(assetName, nameof(assetName));

var url = Client.GenerateApiUrl(_assetListTracksAndDirectoryApiUrl, assetName);
string responseContent = await Client.GetObjectContentAsync(url);
return JsonConvert.DeserializeObject<AssetStorageResponseSchema>(responseContent, ConverterLE.Settings);
Expand Down
4 changes: 3 additions & 1 deletion MK.IO/AssetFilter/AssetFiltersOperations.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using MK.IO.Models;
using Newtonsoft.Json;
using System.Security.Cryptography.X509Certificates;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO.Asset
{
Expand Down
4 changes: 4 additions & 0 deletions MK.IO/ContentKeyPolicy/ContentKeyPoliciesOperations.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion MK.IO/CsharpDotNet2/Model/AzureCredential.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class AzureCredential
/// <value>SAS Token for Azure Storage Account, including leading ?</value>
[DataMember(Name = "sasToken", EmitDefaultValue = false)]
[JsonProperty(PropertyName = "sasToken")]
public string SasToken { get; set; }
public string SasToken { get; set; }

/// <summary>
/// Sanitized token returned in responses from the server. This is the same as the sasToken, but with the signature removed.
Expand Down
3 changes: 3 additions & 0 deletions MK.IO/Job/JobsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

using MK.IO.Models;
using Newtonsoft.Json;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
Expand Down
1 change: 0 additions & 1 deletion MK.IO/Job/Models/JobInputHttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

using Newtonsoft.Json;
using System.Runtime.Serialization;

namespace MK.IO
{
Expand Down
1 change: 0 additions & 1 deletion MK.IO/Job/Models/UtcClipTime.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using MK.IO.Models;
using Newtonsoft.Json;
using System.Runtime.Serialization;
using System.Text;
Expand Down
3 changes: 2 additions & 1 deletion MK.IO/LiveEvent/ILiveEventsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public interface ILiveEventsOperations
/// <returns></returns>
Task<LiveEventSchema> GetAsync(string liveEventName);

#if NET7_0_OR_GREATER
/// <summary>
/// Update a live event
/// </summary>
Expand All @@ -66,7 +67,7 @@ public interface ILiveEventsOperations
/// <param name="tags">A dictionary of tags associated with the live event. Maximum number of tags: 16. Maximum length of a tag: 256 characters.</param>
/// <returns></returns>
Task<LiveEventSchema> UpdateAsync(string liveEventName, string location, LiveEventProperties properties, Dictionary<string, string> tags);

#endif

/// <summary>
/// Create a single live event
Expand Down
5 changes: 5 additions & 0 deletions MK.IO/LiveEvent/LiveEventsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

using MK.IO.Models;
using Newtonsoft.Json;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
Expand Down Expand Up @@ -71,6 +74,7 @@ public async Task<LiveEventSchema> GetAsync(string liveEventName)
return JsonConvert.DeserializeObject<LiveEventSchema>(responseContent, ConverterLE.Settings);
}

#if NET7_0_OR_GREATER
/// <inheritdoc/>
public LiveEventSchema Update(string liveEventName, string location, LiveEventProperties properties, Dictionary<string, string> tags = null)
{
Expand All @@ -87,6 +91,7 @@ public async Task<LiveEventSchema> UpdateAsync(string liveEventName, string loca

return await CreateOrUpdateAsync(liveEventName, location, properties, tags, Client.UpdateObjectAsync);
}
#endif

/// <inheritdoc/>
public LiveEventSchema Create(string liveEventName, string location, LiveEventProperties properties, Dictionary<string, string> tags = null)

Check warning on line 97 in MK.IO/LiveEvent/LiveEventsOperations.cs

View workflow job for this annotation

GitHub Actions / run_test

Cannot convert null literal to non-nullable reference type.

Check warning on line 97 in MK.IO/LiveEvent/LiveEventsOperations.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Cannot convert null literal to non-nullable reference type.

Check warning on line 97 in MK.IO/LiveEvent/LiveEventsOperations.cs

View workflow job for this annotation

GitHub Actions / run_test

Cannot convert null literal to non-nullable reference type.

Check warning on line 97 in MK.IO/LiveEvent/LiveEventsOperations.cs

View workflow job for this annotation

GitHub Actions / create_nuget

Cannot convert null literal to non-nullable reference type.
Expand Down
5 changes: 4 additions & 1 deletion MK.IO/LiveOutput/LiveOutputsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

using MK.IO.Models;
using Newtonsoft.Json;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
Expand Down Expand Up @@ -68,7 +71,7 @@ public async Task<LiveOutputSchema> GetAsync(string liveEventName, string liveOu
{
Argument.AssertNotNullOrEmpty(liveEventName, nameof(liveEventName));
Argument.AssertNotNullOrEmpty(liveOutputName, nameof(liveOutputName));

var url = Client.GenerateApiUrl(_liveOutputApiUrl, liveEventName, liveOutputName);
string responseContent = await Client.GetObjectContentAsync(url);
return JsonConvert.DeserializeObject<LiveOutputSchema>(responseContent, ConverterLE.Settings);
Expand Down
18 changes: 13 additions & 5 deletions MK.IO/MK.IO.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net48</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand All @@ -10,11 +11,11 @@
<Description>A client library for MediaKind MK/IO.</Description>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<RepositoryUrl>https://github.com/xpouyat/MK.IO</RepositoryUrl>
<PackageProjectUrl>https://github.com/xpouyat/MK.IO/blob/master/README.md</PackageProjectUrl>
<AssemblyVersion>1.0.7.0</AssemblyVersion>
<FileVersion>1.0.7.0</FileVersion>
<AssemblyVersion>1.0.8.0</AssemblyVersion>
<FileVersion>1.0.8.0</FileVersion>
<Title>A client library for MediaKind MK/IO.</Title>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand All @@ -41,7 +42,14 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<!-- Conditionally obtain references for the .NET Framework 4.0 target -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>


<ItemGroup>
<Folder Include="CsharpDotNet2\Model\" />
</ItemGroup>

Expand Down
24 changes: 16 additions & 8 deletions MK.IO/MKIOClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

using MK.IO.Asset;
using Newtonsoft.Json;
using System.Collections.Specialized;
using System.Net;
using System.Net.Http.Headers;
using System.Web;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
Expand Down Expand Up @@ -52,9 +54,11 @@ internal Guid GetCustomerId()

public MKIOClient(string MKIOSubscriptionName, string MKIOtoken)
{
_subscriptionName = MKIOSubscriptionName ?? throw new System.ArgumentNullException(nameof(MKIOSubscriptionName));
_apiToken = MKIOtoken ?? throw new System.ArgumentNullException(nameof(MKIOtoken));
Argument.AssertNotNullOrEmpty(MKIOSubscriptionName, nameof(MKIOSubscriptionName));
Argument.AssertNotNullOrEmpty(MKIOtoken, nameof(MKIOtoken));

_subscriptionName = MKIOSubscriptionName;
_apiToken = MKIOtoken;
_httpClient = new HttpClient();

// Request headers
Expand Down Expand Up @@ -164,10 +168,12 @@ internal async Task<string> CreateObjectPostAsync(string url, string amsJSONObje
return await CreateObjectInternalAsync(url, amsJSONObject, HttpMethod.Post);
}

#if NET7_0_OR_GREATER
internal async Task<string> UpdateObjectAsync(string url, string amsJSONObject)
{
return await CreateObjectInternalAsync(url, amsJSONObject, HttpMethod.Patch);
}
#endif

internal async Task<string> CreateObjectInternalAsync(string url, string amsJSONObject, HttpMethod httpMethod)
{
Expand Down Expand Up @@ -291,9 +297,9 @@ internal static string AddParametersToUrl(string url, string name, string? value
if (value != null)
{
UriBuilder baseUri = new(url);
NameValueCollection queryString = HttpUtility.ParseQueryString(baseUri.Query);
var queryString = WebUtility.UrlDecode(baseUri.Query).Split('&');

if (!queryString.HasKeys())
if (queryString.Count() == 1 && string.IsNullOrEmpty(queryString[0]))
{
url += '?';
}
Expand All @@ -302,7 +308,7 @@ internal static string AddParametersToUrl(string url, string name, string? value
url += '&';
}

url += HttpUtility.UrlPathEncode(name + '=' + value);
url += Uri.EscapeUriString(name + '=' + value);
}

return url;
Expand All @@ -316,7 +322,9 @@ internal static string AddParametersToUrl(string url, string name, string? value
/// <returns></returns>
public static string GenerateUniqueName(string prefix, int length = 8)
{
return prefix + "-" + Guid.NewGuid().ToString()[..length];
// return a string of length "length" containing random characters

return prefix + "-" + Guid.NewGuid().ToString("N").Substring(0, length);
}
}
}
4 changes: 3 additions & 1 deletion MK.IO/StorageAccount/StorageAccountsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

using MK.IO.Models;
using Newtonsoft.Json;
using System.Net;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
Expand Down
3 changes: 3 additions & 0 deletions MK.IO/StreamingEndpoint/StreamingEndpointsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

using MK.IO.Models;
using Newtonsoft.Json;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
Expand Down
3 changes: 3 additions & 0 deletions MK.IO/StreamingLocator/StreamingLocatorsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

using MK.IO.Models;
using Newtonsoft.Json;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
Expand Down
3 changes: 1 addition & 2 deletions MK.IO/Transform/Models/AudioAnalysisMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace MK.IO
{
/// <summary>
/// <summary>
/// Determines the set of audio analysis operations to be performed. If unspecified, the Standard AudioAnalysisMode would be chosen.
/// </summary>
/// <value>Determines the set of audio analysis operations to be performed. If unspecified, the Standard AudioAnalysisMode would be chosen.</value>
Expand Down
3 changes: 3 additions & 0 deletions MK.IO/Transform/TransformsOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

using MK.IO.Models;
using Newtonsoft.Json;
#if NET48
using System.Net.Http;
#endif

namespace MK.IO
{
Expand Down
Loading

0 comments on commit a1ddbed

Please sign in to comment.