GithubHelp home page GithubHelp logo

igood / boilerplatezero Goto Github PK

View Code? Open in Web Editor NEW
33.0 2.0 4.0 132 KB

boilerplatezero is a collection of C# source generators

License: MIT License

C# 100.00%
csharp-sourcegenerator csharp source-generators wpf sourcegenerator dependency-property routed-event

boilerplatezero's Issues

error CS0102: The type 'MainWindow' already contains a definition for 'Filename'

I added a DependencyProperty to my WPF project (.NET 5.0, VS 2022) MainWindow class:

private static readonly DependencyPropertyKey FilenamePropertyKey = Gen.Filename<string>();

Visual Studio reports the following errors:

error CS0102: The type 'MainWindow' already contains a definition for 'FilenameProperty'
error CS0102: The type 'MainWindow' already contains a definition for 'Filename'
error CS0111: Type 'MainWindow.Gen' already defines a member called 'Filename' with the same parameter types

The auto-generated file looks fine:

partial class MainWindow
{
    public static readonly DependencyProperty FilenameProperty = FilenamePropertyKey.DependencyProperty;
    /// <summary>Gets the value of the <see cref="FilenameProperty"/> dependency property.</summary>
    public string Filename
    {
        get => (string)this.GetValue(FilenameProperty);
        private set => this.SetValue(FilenamePropertyKey, value);
    }
    private static partial class Gen
    {
        /// <summary>
        /// Registers a read-only dependency property named "Filename" whose type is <typeparamref name="__T"/>.
        /// </summary>
        public static DependencyPropertyKey Filename<__T>()
        {
            var metadata = (PropertyMetadata)null!;
            return DependencyProperty.RegisterReadOnly("Filename", typeof(__T), typeof(MainWindow), metadata, null);
        }
    }
}

What could be causing this? I varied types and names, and if I add a second property, I get errors for that as well. Adding Bpx.Test to my solution causes no problems, the project compiles fine.

Missing support for `FrameworkPropertyMetadataOptions`

Need to support usage something like this...

public static readonly DependencyProperty FooProperty = GenAttached.Foo(
    "asdf", FrameworkPropertyMetadataOptions.Inherits);

public static readonly DependencyProperty BarProperty = Gen.Bar<int>(
    FrameworkPropertyMetadataOptions.BindsTwoWayByDefault);

missing support for property-changed methods

property-changed methods need to be included in the metadata

a string property named Foo should automatically support things like the following methods:

private static void FooPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { }
private static void FooPropertyChanged(MyClass self, DependencyPropertyChangedEventArgs e) { }
protected virtual void OnFooChanged(DependencyPropertyChangedEventArgs e) { }
private void OnFooChanged(string oldFoo, string newFoo) { }

Doc Comments for closed Generic types are invalid

When creating a Dependency Property of a closed generic type (for example, a List<object>) the following documentation comment is generated:

/// <summary>
/// Registers a dependency property named "Objects" whose type is <see cref="System.Collections.Generic.List{object}"/>.
/// </summary>

image

This looks fine, but specifying the type in the {...} is not valid apparently, so it should be:

/// <summary>
/// Registers a dependency property named "Objects" whose type is <see cref="System.Collections.Generic.List{T}"/> of <see cref="object"/>.
/// </summary>

image

or, since you're already using generics for the method signature, just use this:

/// <summary>
/// Registers a dependency property named "Objects" whose type is <typeparamref name="__T"/>.
/// </summary>

image

This causes a compiler warning when GenerateDocumentationFile is enabled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.