Beispiel #1
0
        private void WriteMethodName(IMethodDefinition method)
        {
            if (method.IsConstructor || method.IsStaticConstructor)
            {
                INamedEntity named = method.ContainingTypeDefinition.UnWrap() as INamedEntity;
                if (named != null)
                {
                    WriteIdentifier(named.Name.Value);
                    return;
                }
            }

            if (method.IsExplicitInterfaceMethod())
            {
                IMethodImplementation methodImplementation = method.GetMethodImplementation();
                object nullableAttributeArgument           = methodImplementation.GetExplicitInterfaceMethodNullableAttributeArgument(_metadataReaderCache);
                if (nullableAttributeArgument != null)
                {
                    WriteTypeName(methodImplementation.ImplementedMethod.ContainingType, noSpace: true, nullableAttributeArgument: nullableAttributeArgument);
                    WriteSymbol(".");
                    WriteIdentifier(methodImplementation.ImplementedMethod.Name);
                    return;
                }
            }

            WriteIdentifier(GetNormalizedMethodName(method.Name));
        }
        private void WritePropertyName(IPropertyDefinition property, IMethodDefinition accessor, bool isSetterAccessor, bool isIndexer)
        {
            if (property.IsExplicitInterfaceProperty())
            {
                IMethodImplementation methodImplementation = accessor.GetMethodImplementation();
                object nullableAttributeArgument           = methodImplementation.GetExplicitInterfaceMethodNullableAttributeArgument(_metadataReaderCache);
                if (nullableAttributeArgument != null)
                {
                    WriteTypeName(methodImplementation.ImplementedMethod.ContainingType, noSpace: true, nullableAttributeArgument: nullableAttributeArgument);
                    WriteSymbol(".");
                    if (isIndexer)
                    {
                        WriteIdentifier("this", false);
                        WriteIndexerParameters(accessor, isSetterAccessor);
                    }
                    else
                    {
                        string name = methodImplementation.ImplementedMethod.Name.Value;
                        WriteIdentifier(name.Substring(name.IndexOf("_") + 1));
                    }

                    return;
                }
            }

            if (isIndexer)
            {
                int index = property.Name.Value.LastIndexOf(".");
                if (index >= 0)
                {
                    WriteIdentifier(property.Name.Value.Substring(0, index + 1) + "this", false); // +1 to include the '.'
                }
                else
                {
                    WriteIdentifier("this", false);
                }

                WriteIndexerParameters(accessor, isSetterAccessor);
            }
            else
            {
                WriteIdentifier(property.Name);
            }
        }