Exemple #1
0
        private void WriteMethodBody(IMethodDefinition method)
        {
            if (method.IsAbstract || !_forCompilation || method.IsPlatformInvoke)
            {
                WriteSymbol(";");
                return;
            }

            if (method.IsConstructor)
            {
                WriteBaseConstructorCall(method.ContainingTypeDefinition);
            }

            // Write Dummy Body
            WriteSpace();
            WriteSymbol("{", true);

            if (_platformNotSupportedExceptionMessage != null && !method.IsDispose())
            {
                Write("throw new ");
                if (_forCompilationIncludeGlobalprefix)
                {
                    Write("global::");
                }

                Write("System.PlatformNotSupportedException(");

                if (_platformNotSupportedExceptionMessage.StartsWith("SR."))
                {
                    if (_forCompilationIncludeGlobalprefix)
                    {
                        Write("global::");
                    }
                    Write($"System.{ _platformNotSupportedExceptionMessage}");
                }
                else if (_platformNotSupportedExceptionMessage.Length > 0)
                {
                    Write($"\"{_platformNotSupportedExceptionMessage}\"");
                }

                Write("); ");
            }
            else if (NeedsMethodBodyForCompilation(method))
            {
                Write("throw null; ");
            }

            WriteSymbol("}");
        }