Skip to content

Commit d21dab5

Browse files
committed
Merge pull request #1297 from sergeybykov/1.1.2
Fixes for 1.1.2 release
2 parents 7a6b2c7 + a8a7508 commit d21dab5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1047
-210
lines changed

src/NuGet/BondSerializerInstall.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
param($installPath, $toolsPath, $package, $project)
22

3-
$bondSerializerTypeName = 'Orleans.Serialization.BondSerializer, BondSerializer'
3+
$bondSerializerTypeName = 'Orleans.Serialization.BondSerializer, OrleansBondUtils'
44

55
function AddOrGetElement(
66
[OutputType([System.Xml.XmlElement])]
@@ -9,7 +9,7 @@ function AddOrGetElement(
99
[Parameter(Mandatory=$true)]
1010
[string]$name,
1111
[Parameter(Mandatory=$true)]
12-
[System.Xml.XmlNamespaceManager]$namespaceManager
12+
[System.Xml.XmlNamespaceManager]$namespaceManager
1313
)
1414
{
1515
$node = $xml.ChildNodes | where { $_.Name -eq $name }
@@ -51,7 +51,7 @@ function RegisterSerializer(
5151

5252
$bondTypeProvider = $providersnode.Provider | where { $_.type -eq $type }
5353

54-
if ($bondTypeProvider -eq $null)
54+
if ($bondTypeProvider -eq $null)
5555
{
5656
$provider = AddOrGetElement -xml $providersNode -name "Provider" -namespaceManager $namespaceManager
5757
$typeAttribute = $fileXml.CreateAttribute("type");

src/NuGet/BondSerializerUninstall.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
param($installPath, $toolsPath, $package, $project)
22

3-
$bondSerializerTypeName = 'Orleans.Serialization.BondSerializer, BondSerializer'
3+
$bondSerializerTypeName = 'Orleans.Serialization.BondSerializer, OrleansBondUtils'
44

55
function UnregisterSerializer(
66
[Parameter(Mandatory=$true)]

src/NuGet/Microsoft.Orleans.OrleansAzureUtils.nuspec

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
<dependency id="Microsoft.Orleans.OrleansRuntime" version="$version$" />
2323
<dependency id="Microsoft.Orleans.OrleansProviders" version="$version$" />
2424

25-
<dependency id="WindowsAzure.Storage" version="4.2.0.0" />
26-
<dependency id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.0.0" />
25+
<dependency id="WindowsAzure.Storage" version="5.0.2" />
2726
</dependencies>
2827
</metadata>
2928
<files>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
namespace Orleans.Runtime
2+
{
3+
using System;
4+
5+
/// <summary>
6+
/// Options for formatting type names.
7+
/// </summary>
8+
public class TypeFormattingOptions : IEquatable<TypeFormattingOptions>
9+
{
10+
public TypeFormattingOptions(
11+
string nameSuffix = null,
12+
bool includeNamespace = true,
13+
bool includeGenericParameters = true,
14+
bool includeTypeParameters = true,
15+
char nestedClassSeparator = '.',
16+
bool includeGlobal = true)
17+
{
18+
19+
this.NameSuffix = nameSuffix;
20+
this.IncludeNamespace = includeNamespace;
21+
this.IncludeGenericTypeParameters = includeGenericParameters;
22+
this.IncludeTypeParameters = includeTypeParameters;
23+
this.NestedTypeSeparator = nestedClassSeparator;
24+
this.IncludeGlobal = includeGlobal;
25+
}
26+
27+
/// <summary>
28+
/// Gets a value indicating whether or not to include the fully-qualified namespace of the class in the result.
29+
/// </summary>
30+
public bool IncludeNamespace { get; private set; }
31+
32+
/// <summary>
33+
/// Gets a value indicating whether or not to include concrete type parameters in the result.
34+
/// </summary>
35+
public bool IncludeTypeParameters { get; private set; }
36+
37+
/// <summary>
38+
/// Gets a value indicating whether or not to include generic type parameters in the result.
39+
/// </summary>
40+
public bool IncludeGenericTypeParameters { get; private set; }
41+
42+
/// <summary>
43+
/// Gets the separator used between declaring types and their declared types.
44+
/// </summary>
45+
public char NestedTypeSeparator { get; private set; }
46+
47+
/// <summary>
48+
/// Gets the name to append to the formatted name, before any type parameters.
49+
/// </summary>
50+
public string NameSuffix { get; private set; }
51+
52+
/// <summary>
53+
/// Gets a value indicating whether or not to include the global namespace qualifier.
54+
/// </summary>
55+
public bool IncludeGlobal { get; private set; }
56+
57+
/// <summary>
58+
/// Indicates whether the current object is equal to another object of the same type.
59+
/// </summary>
60+
/// <param name="other">An object to compare with this object.</param>
61+
/// <returns>
62+
/// <see langword="true"/> if the specified object is equal to the current object; otherwise, <see langword="false"/>.
63+
/// </returns>
64+
public bool Equals(TypeFormattingOptions other)
65+
{
66+
if (ReferenceEquals(null, other))
67+
{
68+
return false;
69+
}
70+
if (ReferenceEquals(this, other))
71+
{
72+
return true;
73+
}
74+
return this.IncludeNamespace == other.IncludeNamespace
75+
&& this.IncludeTypeParameters == other.IncludeTypeParameters
76+
&& this.IncludeGenericTypeParameters == other.IncludeGenericTypeParameters
77+
&& this.NestedTypeSeparator == other.NestedTypeSeparator
78+
&& string.Equals(this.NameSuffix, other.NameSuffix) && this.IncludeGlobal == other.IncludeGlobal;
79+
}
80+
81+
/// <summary>
82+
/// Determines whether the specified object is equal to the current object.
83+
/// </summary>
84+
/// <param name="obj">The object to compare with the current object.</param>
85+
/// <returns>
86+
/// <see langword="true"/> if the specified object is equal to the current object; otherwise, <see langword="false"/>.
87+
/// </returns>
88+
public override bool Equals(object obj)
89+
{
90+
if (ReferenceEquals(null, obj))
91+
{
92+
return false;
93+
}
94+
if (ReferenceEquals(this, obj))
95+
{
96+
return true;
97+
}
98+
if (obj.GetType() != this.GetType())
99+
{
100+
return false;
101+
}
102+
return Equals((TypeFormattingOptions)obj);
103+
}
104+
105+
/// <summary>
106+
/// Serves as a hash function for a particular type.
107+
/// </summary>
108+
/// <returns>
109+
/// A hash code for the current object.
110+
/// </returns>
111+
public override int GetHashCode()
112+
{
113+
unchecked
114+
{
115+
var hashCode = this.IncludeNamespace.GetHashCode();
116+
hashCode = (hashCode * 397) ^ this.IncludeTypeParameters.GetHashCode();
117+
hashCode = (hashCode * 397) ^ this.IncludeGenericTypeParameters.GetHashCode();
118+
hashCode = (hashCode * 397) ^ this.NestedTypeSeparator.GetHashCode();
119+
hashCode = (hashCode * 397) ^ (this.NameSuffix != null ? this.NameSuffix.GetHashCode() : 0);
120+
hashCode = (hashCode * 397) ^ this.IncludeGlobal.GetHashCode();
121+
return hashCode;
122+
}
123+
}
124+
125+
public static bool operator ==(TypeFormattingOptions left, TypeFormattingOptions right)
126+
{
127+
return Equals(left, right);
128+
}
129+
130+
public static bool operator !=(TypeFormattingOptions left, TypeFormattingOptions right)
131+
{
132+
return !Equals(left, right);
133+
}
134+
}
135+
}

src/Orleans/CodeGeneration/TypeUtils.cs

+56-48
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal static class TypeUtils
4242
/// </summary>
4343
private static readonly string OrleansCoreAssembly = typeof(IGrain).Assembly.GetName().FullName;
4444

45-
private static readonly ConcurrentDictionary<Tuple<Type, string, bool, bool>, string> ParseableNameCache = new ConcurrentDictionary<Tuple<Type, string, bool, bool>, string>();
45+
private static readonly ConcurrentDictionary<Tuple<Type, TypeFormattingOptions>, string> ParseableNameCache = new ConcurrentDictionary<Tuple<Type, TypeFormattingOptions>, string>();
4646

4747
private static readonly ConcurrentDictionary<Tuple<Type, bool>, List<Type>> ReferencedTypes = new ConcurrentDictionary<Tuple<Type, bool>, List<Type>>();
4848

@@ -60,8 +60,15 @@ public static string GetSimpleTypeName(Type t, Func<Type, bool> fullName=null, L
6060
if (typeInfo.IsNestedPublic || typeInfo.IsNestedPrivate)
6161
{
6262
if (typeInfo.DeclaringType.IsGenericType)
63-
return GetTemplatedName(GetUntemplatedTypeName(typeInfo.DeclaringType.Name), typeInfo.DeclaringType, typeInfo.GetGenericArguments(), _ => true, language) + "." + GetUntemplatedTypeName(typeInfo.Name);
64-
63+
{
64+
return GetTemplatedName(
65+
GetUntemplatedTypeName(typeInfo.DeclaringType.Name),
66+
typeInfo.DeclaringType,
67+
typeInfo.GetGenericArguments(),
68+
_ => true,
69+
language) + "." + GetUntemplatedTypeName(typeInfo.Name);
70+
}
71+
6572
return GetTemplatedName(typeInfo.DeclaringType, language: language) + "." + GetUntemplatedTypeName(typeInfo.Name);
6673
}
6774

@@ -618,25 +625,25 @@ public static string GetUnadornedMethodName(this MethodInfo method)
618625
/// <returns>
619626
/// A string representation of the <paramref name="type"/>.
620627
/// </returns>
621-
public static string GetParseableName(this Type type, string nameSuffix = null, bool includeNamespace = true, bool includeGenericParameters = true)
628+
public static string GetParseableName(this Type type, TypeFormattingOptions options = null)
622629
{
623-
return
624-
ParseableNameCache.GetOrAdd(
625-
Tuple.Create(type, nameSuffix, includeNamespace, includeGenericParameters),
626-
_ =>
627-
{
628-
var builder = new StringBuilder();
629-
var typeInfo = type.GetTypeInfo();
630-
GetParseableName(
631-
type,
632-
nameSuffix ?? string.Empty,
633-
builder,
634-
new Queue<Type>(
635-
typeInfo.IsGenericTypeDefinition ? typeInfo.GetGenericArguments() : typeInfo.GenericTypeArguments),
636-
includeNamespace,
637-
includeGenericParameters);
638-
return builder.ToString();
639-
});
630+
options = options ?? new TypeFormattingOptions();
631+
return ParseableNameCache.GetOrAdd(
632+
Tuple.Create(type, options),
633+
_ =>
634+
{
635+
var builder = new StringBuilder();
636+
var typeInfo = type.GetTypeInfo();
637+
GetParseableName(
638+
type,
639+
builder,
640+
new Queue<Type>(
641+
typeInfo.IsGenericTypeDefinition
642+
? typeInfo.GetGenericArguments()
643+
: typeInfo.GenericTypeArguments),
644+
options);
645+
return builder.ToString();
646+
});
640647
}
641648

642649
/// <summary>
@@ -651,33 +658,28 @@ public static string GetParseableName(this Type type, string nameSuffix = null,
651658
/// <param name="typeArguments">
652659
/// The type arguments of <paramref name="type"/>.
653660
/// </param>
654-
/// <param name="includeNamespace">
655-
/// A value indicating whether or not to include the namespace name.
661+
/// <param name="options">
662+
/// The type formatting options.
656663
/// </param>
657664
private static void GetParseableName(
658665
Type type,
659-
string nameSuffix,
660666
StringBuilder builder,
661667
Queue<Type> typeArguments,
662-
bool includeNamespace = true,
663-
bool includeGenericParameters = true)
668+
TypeFormattingOptions options)
664669
{
665670
var typeInfo = type.GetTypeInfo();
666671
if (typeInfo.IsArray)
667672
{
668673
builder.AppendFormat(
669674
"{0}[{1}]",
670-
typeInfo.GetElementType()
671-
.GetParseableName(
672-
includeNamespace: includeNamespace,
673-
includeGenericParameters: includeGenericParameters),
675+
typeInfo.GetElementType().GetParseableName(options),
674676
string.Concat(Enumerable.Range(0, type.GetArrayRank() - 1).Select(_ => ',')));
675677
return;
676678
}
677679

678680
if (typeInfo.IsGenericParameter)
679681
{
680-
if (includeGenericParameters)
682+
if (options.IncludeGenericTypeParameters)
681683
{
682684
builder.Append(typeInfo.GetUnadornedTypeName());
683685
}
@@ -688,57 +690,63 @@ private static void GetParseableName(
688690
if (typeInfo.DeclaringType != null)
689691
{
690692
// This is not the root type.
691-
GetParseableName(typeInfo.DeclaringType, string.Empty, builder, typeArguments, includeNamespace, includeGenericParameters);
692-
builder.Append('.');
693+
GetParseableName(typeInfo.DeclaringType, builder, typeArguments, options);
694+
builder.Append(options.NestedTypeSeparator);
693695
}
694-
else if (!string.IsNullOrWhiteSpace(type.Namespace) && includeNamespace)
696+
else if (!string.IsNullOrWhiteSpace(type.Namespace) && options.IncludeNamespace)
695697
{
696-
// This is the root type.
697-
builder.AppendFormat("global::{0}.", type.Namespace);
698+
// This is the root type, so include the namespace.
699+
var namespaceName = type.Namespace;
700+
if (options.NestedTypeSeparator != '.')
701+
{
702+
namespaceName = namespaceName.Replace('.', options.NestedTypeSeparator);
703+
}
704+
705+
if (options.IncludeGlobal)
706+
{
707+
builder.AppendFormat("global::");
708+
}
709+
710+
builder.AppendFormat("{0}{1}", namespaceName, options.NestedTypeSeparator);
698711
}
699712

700713
if (typeInfo.IsConstructedGenericType)
701714
{
702715
// Get the unadorned name, the generic parameters, and add them together.
703-
var unadornedTypeName = typeInfo.GetUnadornedTypeName() + nameSuffix;
716+
var unadornedTypeName = typeInfo.GetUnadornedTypeName() + options.NameSuffix;
704717
builder.Append(EscapeIdentifier(unadornedTypeName));
705718
var generics =
706719
Enumerable.Range(0, Math.Min(typeInfo.GetGenericArguments().Count(), typeArguments.Count))
707720
.Select(_ => typeArguments.Dequeue())
708721
.ToList();
709-
if (generics.Count > 0)
722+
if (generics.Count > 0 && options.IncludeTypeParameters)
710723
{
711724
var genericParameters = string.Join(
712725
",",
713-
generics.Select(
714-
generic =>
715-
GetParseableName(
716-
generic,
717-
includeNamespace: includeNamespace,
718-
includeGenericParameters: includeGenericParameters)));
726+
generics.Select(generic => GetParseableName(generic, options)));
719727
builder.AppendFormat("<{0}>", genericParameters);
720728
}
721729
}
722730
else if (typeInfo.IsGenericTypeDefinition)
723731
{
724732
// Get the unadorned name, the generic parameters, and add them together.
725-
var unadornedTypeName = type.GetUnadornedTypeName() + nameSuffix;
733+
var unadornedTypeName = type.GetUnadornedTypeName() + options.NameSuffix;
726734
builder.Append(EscapeIdentifier(unadornedTypeName));
727735
var generics =
728736
Enumerable.Range(0, Math.Min(type.GetGenericArguments().Count(), typeArguments.Count))
729737
.Select(_ => typeArguments.Dequeue())
730738
.ToList();
731-
if (generics.Count > 0)
739+
if (generics.Count > 0 && options.IncludeTypeParameters)
732740
{
733741
var genericParameters = string.Join(
734742
",",
735-
generics.Select(_ => includeGenericParameters ? _.ToString() : string.Empty));
743+
generics.Select(_ => options.IncludeGenericTypeParameters ? _.ToString() : string.Empty));
736744
builder.AppendFormat("<{0}>", genericParameters);
737745
}
738746
}
739747
else
740748
{
741-
builder.Append(EscapeIdentifier(type.GetUnadornedTypeName() + nameSuffix));
749+
builder.Append(EscapeIdentifier(type.GetUnadornedTypeName() + options.NameSuffix));
742750
}
743751
}
744752

src/Orleans/Configuration/ClusterConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ internal static IPAddress GetLocalIPAddress(AddressFamily family = AddressFamily
535535
if (!string.IsNullOrWhiteSpace(interfaceName) &&
536536
!netInterface.Name.StartsWith(interfaceName, StringComparison.Ordinal)) continue;
537537

538-
bool isLoopbackInterface = (i == NetworkInterface.LoopbackInterfaceIndex);
538+
bool isLoopbackInterface = (netInterface.NetworkInterfaceType == NetworkInterfaceType.Loopback);
539539
// get list of all unicast IPs from current interface
540540
UnicastIPAddressInformationCollection ipAddresses = netInterface.GetIPProperties().UnicastAddresses;
541541

src/Orleans/Core/GrainAttributes.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ public static FactoryTypes CollectFactoryTypesSpecified<T>()
302302
[AttributeUsage(AttributeTargets.Class, AllowMultiple=true)]
303303
public sealed class ImplicitStreamSubscriptionAttribute : Attribute
304304
{
305-
internal string Namespace { get; private set; }
306-
305+
public string Namespace { get; private set; }
306+
307307
// We have not yet come to an agreement whether the provider should be specified as well.
308308
public ImplicitStreamSubscriptionAttribute(string streamNamespace)
309309
{

0 commit comments

Comments
 (0)