Skip to content
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,7 @@ ASALocalRun/
Network Trash Folder
Temporary Items
.apdisk

# Exceptions to the exclusions
!src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/*.rsp
!src/Microsoft.DotNet.Wpf/src/WpfGfx/tools/csp/**/*.rsp
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25106.4",
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25106.4"
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25106.4",
"Microsoft.Build.NoTargets": "3.7.56"
},
"sdk": {
"version": "10.0.100-alpha.1.25077.2"
Expand Down
52 changes: 52 additions & 0 deletions src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# MilCodeGen
This directory contains MilCodeGen, which uses the Csp tool to generate source code for the MIL resources.

## How to run MilCodeGen
Run this command at the root of the WPF repo:
```
build.cmd -projects "src\Microsoft.DotNet.Wpf\src\WpfGfx\codegen\mcg\mcg.proj"
```

## Generated files
List of generated resources:
```
src\Microsoft.DotNet.Wpf\src\WpfGfx\Include\Generated\wgx_resource_types.*
src\Microsoft.DotNet.Wpf\src\WpfGfx\Include\Generated\wgx_sdk_version.*
src\Microsoft.DotNet.Wpf\src\WpfGfx\Include\Generated\*_command*
src\Microsoft.DotNet.Wpf\src\WpfGfx\Include\Generated\wgx_misc.*
src\Microsoft.DotNet.Wpf\src\WpfGfx\Include\Generated\wgx_render_types.h
src\Microsoft.DotNet.Wpf\src\WpfGfx\Include\Generated\wincodec_private_generated.h
src\Microsoft.DotNet.Wpf\src\WpfGfx\Include\Generated\wgx_render_types_generated.h
src\Microsoft.DotNet.Wpf\src\WindowsBase\System\Windows\Converters\Generated\.
src\Microsoft.DotNet.Wpf\src\WindowsBase\System\Windows\Generated\.
src\Microsoft.DotNet.Wpf\src\WindowsBase\System\Windows\Media\Generated\.
src\Microsoft.DotNet.Wpf\src\WindowsBase\System\Windows\Media\Converters\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Media3D\Converters\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Media3D\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Media\Animation\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Media\Converters\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Media\Effects\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Media\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Media\Imaging\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationFramework\System\Windows\Generated\.
src\Microsoft.DotNet.Wpf\src\PresentationFramework\System\Windows\Media\Animation\Generated\.
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\Generated\.
src\Microsoft.DotNet.Wpf\src\WpfGfx\codegen\mcg\ResourceModel\Generated\.
src\Microsoft.DotNet.Wpf\src\WpfGfx\core\resources\*_generated.*
src\Microsoft.DotNet.Wpf\src\WpfGfx\core\uce\generated_*
src\Microsoft.DotNet.Wpf\src\WpfGfx\exts\cmdstruct.h
```

List of generated elements:
```
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Generated\UIElement.cs
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Generated\UIElement3D.cs
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Generated\ContentElement.cs
```

## Documentation
Control flow in these templates is as follows:
* Execution starts at ResourceGenerator.Main()
* That method invokes the Go() method on each subclass of GeneratorBase.
i.e. it invokes methods like ManagedResource.Go() and DataStruct.Go().
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ public FileCodeSink(string dir, string filename, bool createDirIfNecessary)
{
Directory.CreateDirectory(dir);
}

_fileCreated = !File.Exists(_filePath);

// If the file exists and is readonly attempt to check out the file.
if (!_fileCreated && ((File.GetAttributes(_filePath) & FileAttributes.ReadOnly) != 0))
{
TfFile(_filePath, "edit");
}

_streamWriter = new StreamWriter(_filePath, false, Encoding.ASCII);
}
Expand All @@ -79,40 +71,6 @@ public void Dispose()
Dispose(true);
}

public static void DisableSd()
{
_disableSd = true;
}

public void TfFile(string filename, string op)
{
if (_tfOperation != "")
{
throw new Exception("Internal error");
}

_tfOperation = op;

if (_disableSd) return;

Process tfProcess = new Process();

tfProcess.StartInfo.FileName = "tf.cmd";
tfProcess.StartInfo.Arguments = op + " " + filename;
tfProcess.StartInfo.CreateNoWindow = true;
tfProcess.StartInfo.UseShellExecute = true;

tfProcess.Start();

tfProcess.WaitForExit();

if (0 != tfProcess.ExitCode)
{
throw new ApplicationException("Non-zero return code (" + tfProcess.ExitCode + ") encountered executing:\n"+
tfProcess.StartInfo.FileName + " " + tfProcess.StartInfo.Arguments);
}
}

#endregion Public Methods

//------------------------------------------------------
Expand Down Expand Up @@ -155,12 +113,6 @@ protected virtual void Dispose(bool disposing)
_streamWriter = null;
}

if (_fileCreated)
{
// If we created the file, we now need to Sd Add it
TfFile(_filePath, "add");
}

LogCreation();
}

Expand Down Expand Up @@ -219,14 +171,8 @@ private void FlushCurrentLine()
// Log the creation of this file, and any sd operations performed.
private void LogCreation()
{
string tf = "";
if (_tfOperation != "")
{
tf = " (and 'tf " + _tfOperation + "')";
}

// Log the creation of this file
Console.WriteLine("\tCreated: {0}{1}", _filePath, tf);
Console.WriteLine("\tCreated: {0}", _filePath);
}
#endregion Private Methods

Expand All @@ -237,11 +183,7 @@ private void LogCreation()
//------------------------------------------------------

#region Private Fields
static bool _disableSd = false;

StreamWriter _streamWriter;
bool _fileCreated = true;
string _tfOperation = "";
string _filePath;
bool disposed = false;
string _currentLine = "";
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ public override void Go(ResourceModel resourceModel)
// requiring that they be split across two namespaces.
switch (instance.ModuleName)
{
case @"Core\CSharp":
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
sridReference =
[[inline]]
using SR=MS.Internal.PresentationCore.SR;
[[/inline]];
break;
case "Framework":
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public AnimationClockResource(ResourceModel rm) : base(rm) {}

public override void Go()
{
// AnimationClockResources end up in src\Core\CSharp\system\windows\media\animation
// AnimationClockResources end up in src\PresentationCore\system\windows\media\animation
string generatedPath = Path.Combine(_resourceModel.OutputDirectory,
"src\\Core\\CSharp\\system\\windows\\media\\animation\\generated");
"src\\PresentationCore\\System\\Windows\\Media\\Animation\\Generated");

foreach (McgResource resource in _resourceModel.Resources)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ public override void Go(ResourceModel resourceModel)
// requiring that they be split across two namespaces.
switch (instance.ModuleName)
{
case @"Core\CSharp":
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
break;
case "Framework":
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public override void Go(ResourceModel resourceModel)
// requiring that they be split across two namespaces.
switch (instance.ModuleName)
{
case @"Core\CSharp":
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
sridReference =
[[inline]]
using SR=MS.Internal.PresentationCore.SR;
[[/inline]];
break;
case "Framework":
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public override void Go()
string generatedPath =
Path.Combine(
_resourceModel.OutputDirectory,
"src\\Graphics\\Include\\Generated"
"src\\WpfGfx\\Include\\Generated"
);

FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_commands.h");;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ public override void Go()
string generatedPath =
Path.Combine(
_resourceModel.OutputDirectory,
"src\\Graphics\\Include\\Generated"
"src\\WpfGfx\\Include\\Generated"
);

string extensionPath =
Path.Combine(
_resourceModel.OutputDirectory,
"src\\Graphics\\exts"
"src\\WpfGfx\\exts"
);

FileCodeSink enumFile =
Expand Down Expand Up @@ -611,7 +611,7 @@ private void EmitCommand(PaddedCommand command, uint value)

m_enum.Write(
[[inline]]
/* [[MilTypeAsHex(value)]] */ [[PadWithSpaces(command.TypeName, 45)]] = 0x[[value.ToString("x02")]],
/* [[MilTypeAsHex(value)]] */ [[PadWithSpaces(command.TypeName, 55)]] = 0x[[value.ToString("x02")]],
[[/inline]]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ private void ProcessNewModule(ResourceModel resourceModel, string moduleName, re
// requiring that they be split across two namespaces.
switch (moduleName)
{
case @"Core\CSharp":
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
break;
case "Framework":
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public DuceResource(ResourceModel rm) : base(rm)
#region Public Methods
public override void Go()
{
FileCodeSink marshalFile = new FileCodeSink(_resourceModel.OutputDirectory, "src\\Graphics\\core\\resources\\marshal_generated.cpp");
FileCodeSink marshalFile = new FileCodeSink(_resourceModel.OutputDirectory, "src\\WpfGfx\\core\\resources\\marshal_generated.cpp");
Helpers.Style.WriteFileHeader(marshalFile);
Helpers.Style.WriteIncludePrecomp(marshalFile);

Expand Down Expand Up @@ -229,7 +229,7 @@ public override void Go()
[[/inline]]
);

FileCodeSink dataFile = new FileCodeSink(_resourceModel.OutputDirectory, "src\\Graphics\\core\\resources\\data_generated.h");
FileCodeSink dataFile = new FileCodeSink(_resourceModel.OutputDirectory, "src\\WpfGfx\\core\\resources\\data_generated.h");
Helpers.Style.WriteFileHeader(dataFile);

// Write lines to ignore deprecation of D3DMATRIX
Expand Down Expand Up @@ -257,7 +257,7 @@ public override void Go()
// we use a hash table as a set.
//

FileCodeSink forwardsFile = new FileCodeSink(_resourceModel.OutputDirectory, "src\\Graphics\\core\\resources\\resources_generated.h");
FileCodeSink forwardsFile = new FileCodeSink(_resourceModel.OutputDirectory, "src\\WpfGfx\\core\\resources\\resources_generated.h");
Helpers.Style.WriteFileHeader(forwardsFile);
Hashtable forwards = new Hashtable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ private void ProcessNewModule(ResourceModel resourceModel, string moduleName, re
// requiring that they be split across two namespaces.
switch (moduleName)
{
case @"Core\CSharp":
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
break;
case "Framework":
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ private void ProcessNewModule(ResourceModel resourceModel, string moduleName, re
// requiring that they be split across two namespaces.
switch (moduleName)
{
case @"Core\CSharp":
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
break;
case "Framework":
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ private void ProcessNewModule(ResourceModel resourceModel, string moduleName, re
// requiring that they be split across two namespaces.
switch (moduleName)
{
case @"Core\CSharp":
case @"PresentationCore":
moduleReference = "using MS.Internal.PresentationCore;";
break;
case "Framework":
case "PresentationFramework":
moduleReference = "using MS.Internal.PresentationFramework;";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,6 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul

valueSerializerConvertTo =
[[inline]]

// When invoked by the serialization engine we can convert to string only for some instances
if (!instance.CanSerializeToString())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override void Go()
string generatedPath =
Path.Combine(
_resourceModel.OutputDirectory,
"src\\Graphics\\Include\\Generated"
"src\\WpfGfx\\Include\\Generated"
);

FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_render_types_generated.h");;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public override void Go()
string generatedPath =
Path.Combine(
_resourceModel.OutputDirectory,
"src\\Graphics\\Include\\Generated"
"src\\WpfGfx\\Include\\Generated"
);

FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_misc.h");;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public override void Go()
string generatedPath =
Path.Combine(
_resourceModel.OutputDirectory,
"src\\Graphics\\Include\\Generated"
"src\\WpfGfx\\Include\\Generated"
);

FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_sdk_version.h");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public override void Go()
string generatedPath =
Path.Combine(
_resourceModel.OutputDirectory,
"src\\Graphics\\Include\\Generated"
"src\\WpfGfx\\Include\\Generated"
);

FileCodeSink ccFile =
Expand Down
Loading