RSCG – ThisClass


name ThisClass
author Trym Lund Flogard

Generate full class name from class


This is how you can use ThisClass .

The code that you start with is

<Project Sdk="Microsoft.NET.Sdk">


		<PackageReference Include="ThisClass" Version="1.5.11" />


The code that you will use is

using DemoClass;

Person person = new Person();
person.Name = "Andrei Ignat";

namespace DemoClass;
internal partial class Person
    public string Name { get; set; }

    public string ClassName => ThisClass.FullName;


The code that is generated is

// <auto-generated/>
#pragma warning disable CS0108, CS1591, CS1573, CS0465, CS0649, CS8019, CS1570, CS1584, CS1658, CS0436, CS8981
#nullable enable
namespace DemoClass;
partial class Person
    public static partial class ThisClass
        /// <summary>
        /// Gets the fully qualified name of the parent class, including the namespace but not the assembly.
        /// </summary>
        public const string FullName = "DemoClass.Person";
// <auto-generated/>
#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
using System;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false, AllowMultiple = true)]
sealed partial class ThisClassAttribute : Attribute

Code and pdf at