Current filter:
                                You should refresh the page.
                                  • I have created a log template to quickly add a static contextual logger at the top of my classes:
                                    private static ILogger _logger = Log.ForContext<«Class»>();
                                    Context: [InClass]
                                    The problem is if I use it within a generic class it does not correctly substitute the class name, it excludes the generic part
                                    e.g.

                                    [C#]
                                    public class MyGenericClass<TInner> { private static ILogger _logger = Log.ForContext<MyGenericClass>(); }

                                    when it should be

                                    [C#]
                                    public class MyGenericClass<TInner> { private static ILogger _logger = Log.ForContext<MyGenericClass<TInner>>(); }

                                    I've also tried «TypeName» with same result
                                    I'm using VS2019 Enterprise 16.2

                                • Igor K. (DevExpress) 08.05.2019

                                  Hi,

                                  Thank you for reaching out to us.
                                  I managed to reproduce the described behavior and forwarded this thread to our R&D team for further research. We'll reply here once we have any results.

                                2 Solutions

                                Creation Date Importance Sort by

                                Fixed:

                                Hi,

                                We have fixed the issue. The «TypeName», «Class» and «FullTypeName» string providers can be parameterized by a boolean value that represents whether it needs to include a list of type arguments. To complete this, change the template definitions as follows:

                                [C#]
                                private static ILogger _logger = Log.ForContext<«Class(true)»>();

                                I've created the gif to illustrate this template expansion.
                                generic-class-template.gif

                                You can find the updated build in the attachment.