Skip to content
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

[SwiftBindings] Added basic C# file support and file writing code #2937

Open
wants to merge 3 commits into
base: feature/swift-bindings
Choose a base branch
from

Conversation

stephen-hawley
Copy link

This adds the basic elements needed to support a simple (empty) C# file with the modern namespace declaration.
This adds a simple CodeWriter for writing elements out.
This adds the elements for C#:

  • CSNamespace - a namespace declaration
  • CSUsing - a using statement
  • CSUsingPackages - a collection of using statements
  • CSComment - a single line comment
  • CSCommentBlock - a collection of single line comments
  • CSTopLevelDeclarations - a collection of top-level declaration objects

Note that several of these types have the fluent method "And" which is useful for chaining things together.
for example:

var comments = new CSCommentBlock().And("Copyright (c) Microsoft Corporation.").And("Licensed under the MIT License.");

@stephen-hawley stephen-hawley added the area-SwiftBindings Swift bindings for .NET label Jan 15, 2025
Copy link
Member

@kotlarmilos kotlarmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove src/Swift.Runtime/src/Metadata/TypeMetadata.cs, I guess it was added by mistake.

@@ -0,0 +1,112 @@
// Copyright (c) Microsoft Corporation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

@@ -0,0 +1,98 @@
// Copyright (c) Microsoft Corporation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this part of the emitter's environment? This should be known by parsing the ABI.

@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this part of the emitter's environment? This should be known by parsing the ABI.

@kotlarmilos
Copy link
Member

kotlarmilos commented Jan 15, 2025

Note that several of these types have the fluent method "And" which is useful for chaining things together.
for example:

var comments = new CSCommentBlock().And("Copyright (c) Microsoft Corporation.").And("Licensed under the MIT License.");

We need this in the string-based emitter as well. I suggest extracting it from the Dynamo.

@jkotas
Copy link
Member

jkotas commented Jan 15, 2025

var comments = new CSCommentBlock().And("Copyright (c) Microsoft Corporation.").And("Licensed under the MIT License.");

This is a fine example. We should not be emitting license headers like this into the generated bindings. The binding generator is a compiler. The default licensing for compiler outputs is that compiler outputs are redistributable without additional restrictions. The only restrictions are based on the license of the compiler inputs used to produce the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-SwiftBindings Swift bindings for .NET
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants