Giter Site home page Giter Site logo

Comments (7)

adamsitnik avatar adamsitnik commented on June 10, 2024 1

cecil should probably switch to TNP for net9-and-above

The new TypeName API is part of System.Reflection.Metadata package, which supports older monikers too:

image

Looks like it's an expected behavior for Type.FullName to return assembly qualified names for generics

Yes, but only for the generic arguments.

> typeof(List<int>).FullName
"System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]"
> typeof(List<int>).AssemblyQualifiedName
"System.Collections.Generic.List`1[[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e"

from xamlx.

maxkatz6 avatar maxkatz6 commented on June 10, 2024

Likely, Cecil one is expected.

Sre is a mix of Type.AssemblyQualifiedName (for generics) and FullName for the main type name itself.

Also, anything that compatible with .NET TypeNameParser is a bonus:
dotnet/runtime#97566

from xamlx.

maxkatz6 avatar maxkatz6 commented on June 10, 2024

Looks like it's an expected behavior for Type.FullName to return assembly qualified names for generics. For some reason.
https://learn.microsoft.com/en-us/dotnet/api/system.type.assemblyqualifiedname?view=net-8.0

from xamlx.

maxkatz6 avatar maxkatz6 commented on June 10, 2024

For your tests, you might want to use these extensions probably:

public static string GetFqn(this IXamlType type) => $"{type.Assembly?.Name}:{type.Namespace}.{type.Name}";
public static string GetFullName(this IXamlType type)
{
var name = type.Name;
if (type.Namespace != null)
name = type.Namespace + "." + name;
if (type.Assembly != null)
name += "," + type.Assembly.Name;
return name;
}

Unless our GetFullName extension is missing generics (which it might do).

from xamlx.

workgroupengineering avatar workgroupengineering commented on June 10, 2024

What do you think if I normalized the Sre FullName like in Cecil instead of using an extension method?

from xamlx.

maxkatz6 avatar maxkatz6 commented on June 10, 2024

I don't know if it will break anything. It would require double checking any FullName usage.
Also, it's still not clear which variant is more standard.

from xamlx.

kasperk81 avatar kasperk81 commented on June 10, 2024

Also, it's still not clear which variant is more standard.

there is no spec: dotnet/runtime#97566 (comment)

in the future, more systems are likely to depend on TypeNameParser's behavior. @adamsitnik may able to clarify some confusion. cecil should probably switch to TNP for net9-and-above

from xamlx.

Related Issues (20)

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.