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

[C#] minor improvement to reduce unused using statements #1070

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yowl
Copy link
Collaborator

@yowl yowl commented Oct 27, 2024

No description provided.

@jsturtevant
Copy link
Collaborator

nice! This has been on the list under #713 "fix imports so they are only included if needed"

@yowl
Copy link
Collaborator Author

yowl commented Oct 28, 2024

There's more 2 do here, but its a start.

@yowl yowl marked this pull request as ready for review October 28, 2024 17:19
Copy link
Collaborator

@jsturtevant jsturtevant left a comment

Choose a reason for hiding this comment

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

Seem the tests are passing. Is there more to do?

@@ -133,6 +121,8 @@ pub enum FunctionLevel {
pub struct CSharp {
opts: Opts,
name: String,
//TODO remove unused
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why the todo here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because its not perfect, the Intefaces in particular still have unused usings, e.g. BindingsWorld.wit.imports.foo.bar.IMyImport.cs has

// Generated by `wit-bindgen` 0.34.0. DO NOT EDIT!
// <auto-generated />
#nullable enable

using System.Text;
using System.Runtime.InteropServices;

namespace BindingsWorld.wit.imports.foo.bar;

public interface IMyImport {

    public class Address {
        public readonly uint field;
        public readonly bool attribute;

        public Address(uint field, bool attribute) {
            this.field = field;
            this.attribute = attribute;
        }
    }

}

Where neither using is required. The generation of the using statements is shared between files which makes it slightly tricky to get this last bit perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants