Skip to content

Commit

Permalink
Downgrade Functions V1 .NET version to net461 (#1257)
Browse files Browse the repository at this point in the history
At one point, we upgraded the full framework target framework from
net461 to net471 to reduce package size for our .NET Standard packages,
as well as to utilize some new language features. This has caused two
problems.

1. When Functions V1 customers target net462, they pull in the
netstandard2.0 version of the dll, which is meant for Functions V2/V3
customers.

2. Using any 4.7 or greater release for Functions V1 breaks when using
Microsoft.NET.Sdk.Functions 1.0.30 or greater, due to some conditional
logic relying on #if NET46. Unfortunately, this version of that package
is required to use Microsoft.Azure.WebJobs 2.3.0 instead of 2.2.0.

This PR reverts to net461 to avoid these issues, as well as some
required code changes to make it compatible with this older version.
  • Loading branch information
Connor McMahon authored Mar 5, 2020
1 parent a874101 commit cf9f4c2
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 10 deletions.
25 changes: 19 additions & 6 deletions src/WebJobs.Extensions.DurableTask/EntityScheduler/EntityId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
/// </summary>
public struct EntityId : IEquatable<EntityId>, IComparable
{
private string schedulerId;

/// <summary>
/// Create an entity id for an entity.
/// </summary>
Expand All @@ -25,6 +27,7 @@ public EntityId(string entityName, string entityKey)

this.EntityName = entityName.ToLowerInvariant();
this.EntityKey = entityKey ?? throw new ArgumentNullException(nameof(entityKey), "Invalid entity id: entity key must not be null.");
this.schedulerId = GetSchedulerId(this.EntityName, this.EntityKey);
}

/// <summary>
Expand All @@ -41,7 +44,12 @@ public EntityId(string entityName, string entityKey)

internal static string GetSchedulerIdFromEntityId(EntityId entityId)
{
return $"@{entityId.EntityName}@{entityId.EntityKey}";
return GetSchedulerId(entityId.EntityName, entityId.EntityKey);
}

private static string GetSchedulerId(string entityName, string entityKey)
{
return $"@{entityName}@{entityKey}";
}

internal static string GetSchedulerIdPrefixFromEntityName(string entityName)
Expand All @@ -60,7 +68,13 @@ internal static EntityId GetEntityIdFromSchedulerId(string schedulerId)
/// <inheritdoc/>
public override string ToString()
{
return GetSchedulerIdFromEntityId(this);
// The scheduler id could be null if the object was deserialized.
if (this.schedulerId == null)
{
this.schedulerId = GetSchedulerIdFromEntityId(this);
}

return this.schedulerId;
}

/// <inheritdoc/>
Expand All @@ -72,21 +86,20 @@ public override bool Equals(object obj)
/// <inheritdoc/>
public bool Equals(EntityId other)
{
return (this.EntityName, this.EntityKey).Equals((other.EntityName, other.EntityKey));
return this.ToString().Equals(other.ToString());
}

/// <inheritdoc/>
public override int GetHashCode()
{
return (this.EntityName, this.EntityKey).GetHashCode();
return this.ToString().GetHashCode();
}

/// <inheritdoc/>
public int CompareTo(object obj)
{
var other = (EntityId)obj;
return ((IComparable)(this.EntityKey, this.EntityName))
.CompareTo((other.EntityKey, other.EntityName));
return this.ToString().CompareTo(other.ToString());
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ internal bool IsSanitizedHubName(string hubName, out string sanitizedHubName)
// a number. If it does, prepend "t" to the beginning.
if (char.IsNumber(validHubNameCharacters.First()))
{
validHubNameCharacters = validHubNameCharacters.Prepend('t');
validHubNameCharacters = validHubNameCharacters.ToList();
((List<char>)validHubNameCharacters).Insert(0, 't');
}

sanitizedHubName = new string(validHubNameCharacters
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net471</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<AssemblyName>Microsoft.Azure.WebJobs.Extensions.DurableTask</AssemblyName>
<RootNamespace>Microsoft.Azure.WebJobs.Extensions.DurableTask</RootNamespace>
<MajorVersion>2</MajorVersion>
Expand All @@ -11,6 +11,7 @@
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>
<Company>Microsoft Corporation</Company>
<LangVersion>7.3</LangVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\sign.snk</AssemblyOriginatorKeyFile>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand Down
2 changes: 1 addition & 1 deletion test/Common/TestOrchestrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public static DurableHttpRequest ConvertTestRequestToDurableHttpRequest(TestDura
StringValues stringValues;
if (testHeaders.TryGetValue(header.Key, out stringValues))
{
stringValues.Append(header.Value);
stringValues = StringValues.Concat(stringValues, header.Value);
testHeaders[header.Key] = stringValues;
}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<TargetFramework>net461</TargetFramework>
<Company>Microsoft Corporation</Company>
<NoWarn>SA0001;SA1600;SA1615</NoWarn>
<SignAssembly>true</SignAssembly>
Expand Down

0 comments on commit cf9f4c2

Please sign in to comment.