Skip to content

Commit

Permalink
Update Reference Source to .NET Framework 4.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot authored and richlander committed Aug 5, 2016
1 parent 69fac85 commit 1acafe2
Show file tree
Hide file tree
Showing 209 changed files with 5,526 additions and 1,733 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ protected override void OnRender(DrawingContext drawingContext)
trueLabelText = (string)virtualizingContainer.ModelItem.Properties["TrueLabel"].ComputedValue;
}

double pixelsPerDip = VisualTreeHelper.GetDpi(trueConnectionPoint).PixelsPerDip;
actualPoint = new Point(trueConnectionPoint.Location.X - origin.X, trueConnectionPoint.Location.Y - origin.Y);
FormattedText trueMarkerFormattedText = new FormattedText(trueLabelText, new System.Globalization.CultureInfo(textCulture),
this.FlowDirection, FlowchartDesigner.FlowElementCaptionTypeface, FlowchartDesigner.FlowNodeCaptionFontSize,
new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementCaptionColor));
new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementCaptionColor), pixelsPerDip);
actualPoint.Y += ConnectionPoint.DrawingLargeSide / 2;
actualPoint.X -= trueMarkerFormattedText.WidthIncludingTrailingWhitespace;

Expand Down Expand Up @@ -94,9 +95,10 @@ protected override void OnRender(DrawingContext drawingContext)
actualPoint = new Point(falseConnectionPoint.Location.X - origin.X, falseConnectionPoint.Location.Y - origin.Y);
actualPoint.Y += ConnectionPoint.DrawingLargeSide / 2;

double pixelsPerDip = VisualTreeHelper.GetDpi(falseConnectionPoint).PixelsPerDip;
FormattedText falseMarkerFormattedText = new FormattedText(falseLabelText, new System.Globalization.CultureInfo(textCulture),
this.FlowDirection, FlowchartDesigner.FlowElementCaptionTypeface, FlowchartDesigner.FlowNodeCaptionFontSize,
new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementCaptionColor));
new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementCaptionColor), pixelsPerDip);

DrawtWithTransform(
drawingContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Microsoft.Activities.Presentation.Xaml
using System;
using System.Activities;
using System.Activities.Debugger;
using System.Activities.DynamicUpdate;
using System.Activities.Presentation.View;
using System.Activities.Presentation.ViewState;
using System.Collections.Generic;
Expand All @@ -30,6 +31,18 @@ internal static class ViewStateXamlHelper
XamlDebuggerXmlReader.EndColumnName.MemberName
};

// These are used to discover that we have found a DynamicUpdateInfo.OriginalDefintion or OriginalActivityBuilder
// attached property member. We have "hardcoded" the *MemberName" here because DynamicUpdateInfo has the
// AttachableMemberIdentifier properties marked as private. But the DynamicUpdateInfo class itself is public,
// as are the Get and Set methods.
static readonly string DynamicUpdateOriginalDefinitionMemberName = "OriginalDefinition";
static readonly MethodInfo GetOriginalDefinition = typeof(DynamicUpdateInfo).GetMethod("GetOriginalDefinition");
static readonly MethodInfo SetOriginalDefinition = typeof(DynamicUpdateInfo).GetMethod("SetOriginalDefinition");

static readonly string DynamicUpdateOriginalActivityBuilderMemberName = "OriginalActivityBuilder";
static readonly MethodInfo GetOriginalActivityBuilder = typeof(DynamicUpdateInfo).GetMethod("GetOriginalActivityBuilder");
static readonly MethodInfo SetOriginalActivityBuilder = typeof(DynamicUpdateInfo).GetMethod("SetOriginalActivityBuilder");

// This method collects view state attached properties and generates a Xaml node stream
// with all view state information appearing within the ViewStateManager node.
// It is called when workflow definition is being serialized to string.
Expand Down Expand Up @@ -279,6 +292,22 @@ public static XamlReader ConvertViewStateToAttachedProperties(XamlReader inputRe
// Xaml member definition for IdRef. Used to identify existing IdRef properties in the input nodestream.
XamlMember idRefMember = new XamlMember(IdRef, GetIdRef, SetIdRef, inputReader.SchemaContext);

// These are used to ignore the IdRef members that are inside a DynamicUpdateInfo.OriginalDefinition/OriginalActivityBuilder attached property.
// We need to ignore these because if we don't, the IdRef values for the objects in the actual workflow defintion will be ignored because of the
// duplicate IdRef value. This causes problems with activity designers that depend on the ViewStateManager data to correctly display the workflow
// on the WorkflowDesigner canvas.
XamlMember originalDefinitionMember = new XamlMember(DynamicUpdateOriginalDefinitionMemberName, GetOriginalDefinition, SetOriginalDefinition, inputReader.SchemaContext);
XamlMember originalActivityBuilderMember = new XamlMember(DynamicUpdateOriginalActivityBuilderMemberName, GetOriginalActivityBuilder, SetOriginalActivityBuilder, inputReader.SchemaContext);

// insideOriginalDefintion gets set to true when we find a "StartMember" node for either of the above two attached properties.
// originalDefintionMemberCount gets incremented if we find any "StartMember" and insideOriginalDefinition is true.
// originalDefintionMemberCount gets decremented if we find any "EndMember" and insideOriginalDefintion is true.
// insideOriginalDefintion gets set to false when we find an "EndMember" and originalDefinitionMemberCount gets decremented to 0.
// If insideOriginalDefintion is true when we find an "IdRef" member, we do NOT add that IdRef to the idRefsSeen HashSet to avoid
// duplicates being defined by the IdRefs inside of the OriginalDefinition attached properties.
bool insideOriginalDefinition = false;
int originalDefinitionMemberCount = 0;

// Dictionary containing Ids and corresponding viewstate related
// attached property nodes. Populated by StripViewStateElement method.
Dictionary<string, XamlNodeList> viewStateInfo = null;
Expand Down Expand Up @@ -323,9 +352,21 @@ public static XamlReader ConvertViewStateToAttachedProperties(XamlReader inputRe
break;

case XamlNodeType.StartMember:
// If we find a StartMember for DynamicUpdateInfo.OriginalDefinition or OriginalActivityBuilder, remember that we are
// inside one of those. We don't want to "remember" IdRef values in the idRefsSeen HashSet while inside these attached properties.
if (workflowDefinition.Member.Equals(originalDefinitionMember) || workflowDefinition.Member.Equals(originalActivityBuilderMember))
{
insideOriginalDefinition = true;
}

if (insideOriginalDefinition)
{
originalDefinitionMemberCount++;
}

// Track when the reader enters IdRef. Skip writing the start
// node to the output nodelist until we check for duplicates.
if (workflowDefinition.Member.Equals(idRefMember))
else if (workflowDefinition.Member.Equals(idRefMember))
{
inIdRefMember = true;
skipWritingWorkflowDefinition = true;
Expand All @@ -341,38 +382,43 @@ public static XamlReader ConvertViewStateToAttachedProperties(XamlReader inputRe
case XamlNodeType.Value:
if (inIdRefMember)
{
string idRef = workflowDefinition.Value as string;
if (!string.IsNullOrWhiteSpace(idRef))
// We don't want to deal with the IdRef if we are inside a DynamicUpdateInfo.OriginalDefinition/OriginalActivityBuilder
// attached property.
if (!insideOriginalDefinition)
{
// If IdRef value is a duplicate then do not associate it with
// the stack frame (top of stack == activity node with IdRef member on it).
if (idRefsSeen.Contains(idRef))
{
stack.Peek().IdRef = null;
}
// If the IdRef value is unique then associate it with the
// stack frame and also write its value into the output nodestream.
else
string idRef = workflowDefinition.Value as string;
if (!string.IsNullOrWhiteSpace(idRef))
{
stack.Peek().IdRef = idRef;
idManager.UpdateMap(idRef);
idRefsSeen.Add(idRef);

if (shouldPassLineInfo)
// If IdRef value is a duplicate then do not associate it with
// the stack frame (top of stack == activity node with IdRef member on it).
if (idRefsSeen.Contains(idRef))
{
lineInfoComsumer.SetLineInfo(idRefLineNumber, idRefLinePosition);
stack.Peek().IdRef = null;
}
// If the IdRef value is unique then associate it with the
// stack frame and also write its value into the output nodestream.
else
{
stack.Peek().IdRef = idRef;
idManager.UpdateMap(idRef);
idRefsSeen.Add(idRef);

mergedNodeWriter.WriteStartMember(idRefMember);
if (shouldPassLineInfo)
{
lineInfoComsumer.SetLineInfo(idRefLineNumber, idRefLinePosition);
}

if (shouldPassLineInfo)
{
lineInfoComsumer.SetLineInfo(lineInfo.LineNumber, lineInfo.LinePosition);
}
mergedNodeWriter.WriteStartMember(idRefMember);

mergedNodeWriter.WriteValue(idRef);
if (shouldPassLineInfo)
{
lineInfoComsumer.SetLineInfo(lineInfo.LineNumber, lineInfo.LinePosition);
}

shouldWriteIdRefEndMember = true;
mergedNodeWriter.WriteValue(idRef);

shouldWriteIdRefEndMember = true;
}
}
}
// Don't need to write IdRef value into the output
Expand All @@ -382,9 +428,21 @@ public static XamlReader ConvertViewStateToAttachedProperties(XamlReader inputRe
break;

case XamlNodeType.EndMember:
// If we are inside an OriginalDefinition/OriginalActivityBuilder attached property,
// decrement the count and if it goes to zero, set insideOriginalDefintion to false
// because we just encountered the EndMember for it.
if (insideOriginalDefinition)
{
originalDefinitionMemberCount--;
if (originalDefinitionMemberCount == 0)
{
insideOriginalDefinition = false;
}
}

// Exit IdRef node. Skip writing the EndMember node, we would have done
// it as part of reading the IdRef value.
if (inIdRefMember)
if (inIdRefMember && !insideOriginalDefinition)
{
inIdRefMember = false;
skipWritingWorkflowDefinition = true;
Expand All @@ -401,6 +459,7 @@ public static XamlReader ConvertViewStateToAttachedProperties(XamlReader inputRe
mergedNodeWriter.WriteEndMember();
}
}

break;

case XamlNodeType.EndObject:
Expand Down Expand Up @@ -592,6 +651,7 @@ static XamlReader StripViewStateElement(XamlReader inputReader, out Dictionary<s
viewStateSourceLocationMap = null;
XamlNodeList strippedNodeList = new XamlNodeList(inputReader.SchemaContext);
XamlMember viewStateManager = new XamlMember(ViewStateManager, GetViewStateManager, SetViewStateManager, inputReader.SchemaContext);

using (XamlWriter strippedWriter = strippedNodeList.Writer)
{
IXamlLineInfo lineInfo = inputReader as IXamlLineInfo;
Expand All @@ -618,7 +678,7 @@ static XamlReader StripViewStateElement(XamlReader inputReader, out Dictionary<s

return strippedNodeList.GetReader();
}

// This method reads ViewStateManager nodes from the xaml nodestream and outputs that in the
// viewStateInfo dictionary. The input reader is positioned on the ViewStateManagerNode in the nodestream.
static void ReadViewStateInfo(XamlReader inputReader, out Dictionary<string, XamlNodeList> viewStateInfo, out Dictionary<string, SourceLocation> viewStateSourceLocationMap)
Expand Down Expand Up @@ -700,7 +760,11 @@ static void ReadViewState(XamlType viewStateType, XamlReader xamlReader, out str
}
}
}
else if (globalMemberLevel == 1 && !IsAttachablePropertyForConvert(xamlReader))
// The xamlReader.ReadSubtree and subsequent while loop to get the Id member
// has moved the xamlReader forward to the next member. We need to check to see
// if it is an Attached Property that we care about. If it isn't then we need to
// skip it and not put it in the resulting XamlNodeList.
if (globalMemberLevel == 1 && !IsAttachablePropertyForConvert(xamlReader))
{
skippingUnexpectedAttachedProperty = true;
}
Expand Down
14 changes: 14 additions & 0 deletions System.Activities/System/Activities/Hosting/WorkflowInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ public abstract class WorkflowInstance
StackTrace abortStack;
#endif

static WorkflowInstance()
{
try
{
using (TelemetryEventSource eventSource = new TelemetryEventSource())
{
eventSource.V2Runtime();
}
}
catch
{
}
}

protected WorkflowInstance(Activity workflowDefinition)
: this(workflowDefinition, null)
{
Expand Down
2 changes: 1 addition & 1 deletion System.Activities/System/Activities/WorkflowApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public sealed class WorkflowApplication : WorkflowInstance
IList<Handle> rootExecutionProperties;

IDictionary<XName, InstanceValue> instanceMetadata;

public WorkflowApplication(Activity workflowDefinition)
: this(workflowDefinition, (WorkflowIdentity)null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public static bool UseLegacyRegExTimeout {
}

public static void SetDefaultsLessOrEqual_46() {
#pragma warning disable BCL0012 //disable warning about AppContextDefaults not following the recommended pattern
// Define the switches that should be true for 4.6 or less, false for 4.6.1+.
LocalAppContext.DefineSwitchDefault(UseLegacyRegExTimeoutString, true);
#pragma warning restore BCL0012
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.ComponentModel.DataAnnotations.Resources;
using System.ComponentModel.DataAnnotations.Resources;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text.RegularExpressions;
Expand All @@ -19,7 +19,18 @@ public class RegularExpressionAttribute : ValidationAttribute {
/// Gets or sets the timeout to use when matching the regular expression pattern (in milliseconds)
/// (-1 means never timeout).
/// </summary>
public int MatchTimeoutInMilliseconds { get; set; } = GetDefaultTimeout();
public int MatchTimeoutInMilliseconds {
get {
return _matchTimeoutInMilliseconds;
}
set {
_matchTimeoutInMilliseconds = value;
_matchTimeoutSet = true;
}
}

private int _matchTimeoutInMilliseconds;
private bool _matchTimeoutSet;

private Regex Regex { get; set; }

Expand Down Expand Up @@ -90,6 +101,11 @@ private void SetupRegex() {
if (string.IsNullOrEmpty(this.Pattern)) {
throw new InvalidOperationException(DataAnnotationsResources.RegularExpressionAttribute_Empty_Pattern);
}

if (!_matchTimeoutSet) {
MatchTimeoutInMilliseconds = GetDefaultTimeout();
}

Regex = MatchTimeoutInMilliseconds == -1
? new Regex(Pattern)
: Regex = new Regex(Pattern, default(RegexOptions), TimeSpan.FromMilliseconds((double)MatchTimeoutInMilliseconds));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==

// There are cases where we have multiple assemblies that are going to import this file and
// if they are going to also have InternalsVisibleTo between them, there will be a compiler warning
// that the type is found both in the source and in a referenced assembly. The compiler will prefer
// the version of the type defined in the source
//
// In order to disable the warning for this type we are disabling this warning for this entire file.
#pragma warning disable 436

using System;
using System.Collections.Generic;

Expand Down Expand Up @@ -167,3 +176,5 @@ private static bool TryParseFrameworkName(String frameworkName, out String ident
static partial void PopulateDefaultValuesPartial(string platformIdentifier, string profile, int version);
}
}

#pragma warning restore 436
Loading

0 comments on commit 1acafe2

Please sign in to comment.