Skip to content

Sync MilCodeGen to generated code #10430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,8 @@ public override void Go(ResourceModel resourceModel)
csFile.WriteBlock(
[[inline]]
[[Helpers.ManagedStyle.WriteFileHeader(filename, @"wpf\src\Graphics\codegen\mcg\generators\AnimatableTemplate.cs")]]

using MS.Internal;
using MS.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security;
using System.Security.Permissions;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;

using SR = MS.Internal.PresentationCore.SR;
using System.Windows.Media.Animation;

namespace [[instance.Namespace]]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,53 +69,16 @@ public override void Go(ResourceModel resourceModel)

string fullPath = Path.Combine(resourceModel.OutputDirectory, path);

string moduleReference;
string sridReference =
[[inline]]
using SR=System.Windows.SR;
[[/inline]];

// Duplicate AnimatedTypeHelpers class across Core/Framework causes name conflicts,
// requiring that they be split across two namespaces.
switch (instance.ModuleName)
{
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
sridReference =
[[inline]]
using SR=MS.Internal.PresentationCore.SR;
[[/inline]];
break;
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
default:
moduleReference = "";
break;
}


using (FileCodeSink csFile = new FileCodeSink(fullPath, fileName, true /* Create dir if necessary */))
{
csFile.WriteBlock(
[[inline]]
[[Helpers.ManagedStyle.WriteFileHeader(fileName)]]

using MS.Internal;

using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;

[[moduleReference]]

[[sridReference]]

namespace System.Windows.Media.Animation
{
{
/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -293,14 +256,8 @@ private string WriteIAnimationGetCurrentValueBody(AnimationBaseTemplateInstance
nullCheck =
[[inline]]
// Verify that object arguments are non-null since we are a value type
if (defaultOriginValue == null)
{
throw new ArgumentNullException("defaultOriginValue");
}
if (defaultDestinationValue == null)
{
throw new ArgumentNullException("defaultDestinationValue");
}
ArgumentNullException.ThrowIfNull(defaultOriginValue);
ArgumentNullException.ThrowIfNull(defaultDestinationValue);
[[/inline]];
}

Expand All @@ -321,10 +278,7 @@ private string WriteTypedGetCurrentValueBody(AnimationBaseTemplateInstance insta
[[inline]]
ReadPreamble();

if (animationClock == null)
{
throw new ArgumentNullException("animationClock");
}
ArgumentNullException.ThrowIfNull(animationClock);

if (animationClock.CurrentState == ClockState.Stopped)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,7 @@ public override void Go()
[[inline]]
[[Helpers.ManagedStyle.WriteFileHeader(fileName)]]

using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Composition;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;

namespace System.Windows.Media.Animation
{
Expand Down Expand Up @@ -173,21 +167,16 @@ protected override DUCE.ResourceType ResourceType
/// </summary>
/// <param name="handle"> The DUCE.ResourceHandle for this resource on this channel. </param>
/// <param name="channel"> The channel on which to update the render-thread resource. </param>
/// <SecurityNote>
/// Critical: This code calls into an unsafe code block
/// TreatAsSafe: This code does not return any critical data.It is ok to expose
/// Channels can handle bad pointers and will not affect other appdomains or processes
/// </SecurityNote>
[SecurityCritical,SecurityTreatAsSafe]
protected override void UpdateResource(
DUCE.ResourceHandle handle,
DUCE.Channel channel)
{
DUCE.MILCMD_[[nameAsUpper]]RESOURCE cmd = new DUCE.MILCMD_[[nameAsUpper]]RESOURCE();

cmd.Type = MILCMD.MilCmd[[resource.Name]]Resource;
cmd.Handle = handle;
cmd.Value = CurrentValue;
DUCE.MILCMD_[[nameAsUpper]]RESOURCE cmd = new DUCE.MILCMD_[[nameAsUpper]]RESOURCE
{
Type = MILCMD.MilCmd[[resource.Name]]Resource,
Handle = handle,
Value = CurrentValue
};

unsafe
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,8 @@ public override void Go(ResourceModel resourceModel)
[[inline]]
[[Helpers.ManagedStyle.WriteFileHeader(fileName, @"wpf\src\Graphics\codegen\mcg\generators\AnimationResourceTemplate.cs")]]

using System;
using MS.Internal;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;

using System.Windows.Media;
using System.Windows.Media.Composition;
using System.Windows.Media.Media3D;
using System.Security;
using System.Security.Permissions;

namespace System.Windows.Media.Animation
{
Expand All @@ -91,11 +82,6 @@ protected override DUCE.ResourceType ResourceType
}
}

/// <SecurityNote>
/// Critical: This code is critical because it has unsafe code blocks
/// TreatAsSafe: This call is ok to expose. Channels can handle bad pointers
/// </SecurityNote>
[SecurityCritical,SecurityTreatAsSafe]
protected override void UpdateResourceCore(DUCE.Channel channel)
{
Debug.Assert(_duceResource.IsOnChannel(channel));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,14 @@ public override void Go(ResourceModel resourceModel)
[[inline]]
[[Helpers.ManagedStyle.WriteFileHeader(fileName)]]

using MS.Internal;
using MS.Internal.KnownBoxes;
using MS.Utility;

using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Media.Animation;

[[moduleReference]]

namespace System.Windows.Media.Animation
{

{
/// <summary>
/// Animates the value of a [[instance.TypeName]] property using linear interpolation
/// between two values. The values are determined by the combination of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,13 @@ public override void Go(ResourceModel resourceModel)
string fullPath = Path.Combine(resourceModel.OutputDirectory, path);

string moduleReference = "";
string sridReference =
[[inline]]
using SR=System.Windows.SR;
[[/inline]];

// Duplicate AnimatedTypeHelpers class across Core/Framework causes name conflicts,
// requiring that they be split across two namespaces.
switch (instance.ModuleName)
{
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
sridReference =
[[inline]]
using SR=MS.Internal.PresentationCore.SR;
[[/inline]];
break;
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
Expand All @@ -95,21 +87,11 @@ public override void Go(ResourceModel resourceModel)
[[inline]]
[[Helpers.ManagedStyle.WriteFileHeader(fileName)]]

using MS.Internal;
using MS.Internal.KnownBoxes;

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;

[[sridReference]]

using System.Windows.Media.Media3D;
[[moduleReference]]

namespace System.Windows.Media.Animation
Expand Down Expand Up @@ -299,10 +281,7 @@ void IAddChild.AddChild(object child)
{
WritePreamble();

if (child == null)
{
throw new ArgumentNullException("child");
}
ArgumentNullException.ThrowIfNull(child);

AddChild(child);

Expand All @@ -324,7 +303,7 @@ protected virtual void AddChild(object child)
}
else
{
throw new ArgumentException(SR.Animation_ChildMustBeKeyFrame, "child");
throw new ArgumentException(SR.Animation_ChildMustBeKeyFrame, nameof(child));
}
}

Expand All @@ -343,10 +322,7 @@ protected virtual void AddChild(object child)
/// null.</exception>
void IAddChild.AddText(string childText)
{
if (childText == null)
{
throw new ArgumentNullException("childText");
}
ArgumentNullException.ThrowIfNull(childText);

AddText(childText);
}
Expand Down Expand Up @@ -612,10 +588,7 @@ public [[instance.TypeName]]KeyFrameCollection KeyFrames
}
set
{
if (value == null)
{
throw new ArgumentNullException("value");
}
ArgumentNullException.ThrowIfNull(value);

WritePreamble();

Expand Down Expand Up @@ -819,7 +792,7 @@ private void ResolveKeyTimes()
}

int maxKeyFrameIndex = keyFrameCount - 1;
ArrayList unspecifiedBlocks = new ArrayList();
List<KeyTimeBlock> unspecifiedBlocks = new List<KeyTimeBlock>();
bool hasPacedKeyTimes = false;

//
Expand Down Expand Up @@ -886,8 +859,10 @@ private void ResolveKeyTimes()
hasPacedKeyTimes = true;
}

KeyTimeBlock block = new KeyTimeBlock();
block.BeginIndex = index;
KeyTimeBlock block = new KeyTimeBlock
{
BeginIndex = index
};

// NOTE: We don't want to go all the way up to the
// last frame because if it is Uniform or Paced its
Expand Down Expand Up @@ -931,7 +906,7 @@ private void ResolveKeyTimes()

for (int j = 0; j < unspecifiedBlocks.Count; j++)
{
KeyTimeBlock block = (KeyTimeBlock)unspecifiedBlocks[j];
KeyTimeBlock block = unspecifiedBlocks[j];

TimeSpan blockBeginTime = TimeSpan.Zero;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,9 @@ public override void Go()
[[inline]]
// This code is generated from mcg\generators\CommandStructure.cs

using System;
using System.Windows.Media.Composition;
using System.Runtime.InteropServices;
using System.Windows.Media.Effects;
using System.Security;

using BOOL = System.UInt32;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ private void ProcessNewModule(ResourceModel resourceModel, string moduleName, re
string fileName = "DiscreteKeyFrames.cs";
string path = null;
string fullPath = null;
string moduleReference = null;

//
// Create a new file
Expand All @@ -183,18 +182,6 @@ private void ProcessNewModule(ResourceModel resourceModel, string moduleName, re
path = "src\\" + moduleName + "\\System\\Windows\\Media\\Animation\\Generated";
fullPath = Path.Combine(resourceModel.OutputDirectory, path);

// Duplicate AnimatedTypeHelpers class across Core/Framework causes name conflicts,
// requiring that they be split across two namespaces.
switch (moduleName)
{
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
break;
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
}

csFile = new FileCodeSink(fullPath, fileName, true /* Create dir if necessary */);

//
Expand All @@ -205,17 +192,8 @@ private void ProcessNewModule(ResourceModel resourceModel, string moduleName, re
[[inline]]
[[Helpers.ManagedStyle.WriteFileHeader(fileName)]]

using MS.Internal;

using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Media;
using System.Windows.Media.Media3D;

[[moduleReference]]

namespace System.Windows.Media.Animation
{
[[/inline]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ McgResource dataType

codeSink.WriteBlock(
[[inline]]
HRESULT [[dataType.DuceClass]]::RegisterNotifiers(CMilSlaveHandleTable *pHandleTable)
HRESULT [[dataType.DuceClass]]::RegisterNotifiers(__in_ecount(1) CMilSlaveHandleTable *pHandleTable)
{
HRESULT hr = S_OK;

Expand Down
Loading