diff --git a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs index f9b7b294b08a..49fea4eb40cb 100644 --- a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs +++ b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs @@ -58,7 +58,7 @@ public bool NoTypeReuse internal const string WCFCSParamsFileName = "ConnectedService.json"; internal const string BaseServiceReferenceName = "ServiceReference"; - private static readonly List s_cmdLineOverwriteSwitches = new List { Switches.NoLogo.Name, Switches.Verbosity.Name, Switches.ToolContext.Name, Switches.ProjectFile.Name, Switches.AcceptCertificate.Name, Switches.ServiceContract.Name }; + private static readonly List s_cmdLineOverwriteSwitches = new List { Switches.NoLogo.Name, Switches.Verbosity.Name, Switches.ToolContext.Name, Switches.ProjectFile.Name, Switches.AcceptCertificate.Name, Switches.ServiceContract.Name, Switches.Language.Name }; internal class CommandSwitches { @@ -92,6 +92,7 @@ internal class CommandSwitches public readonly CommandSwitch Wrapped = new CommandSwitch(WrappedKey, "wr", SwitchType.Flag); public readonly CommandSwitch AcceptCertificate = new CommandSwitch(AccecptCertificateKey, "ac", SwitchType.Flag); public readonly CommandSwitch ServiceContract = new CommandSwitch(ServiceContractKey, "sc", SwitchType.Flag); + public readonly CommandSwitch Language = new CommandSwitch(LanguageKey, "l", SwitchType.SingletonValue, OperationalContext.Global); public void Init() { } // provided as a way to get the static class Switches loaded early. } @@ -198,13 +199,13 @@ public async Task ResolveAsync(CancellationToken cancellationToken) { if (this.Help != true && this.Errors.Count() == 0) { - ProcessLanguageOption(); - ProcessSerializerOption(); // process project file first as it can define the working directory. await ProcessProjectFileOptionAsync(cancellationToken).ConfigureAwait(false); + ProcessLanguageOption(); + // next update option as the options may change. await ProcessUpdateOptionAsync(cancellationToken).ConfigureAwait(false); @@ -330,27 +331,32 @@ private async Task ProcessProjectFileOptionAsync(CancellationToken cancellationT using (SafeLogger logger = await SafeLogger.WriteStartOperationAsync(this.Logger, $"Resolving {ProjectFileKey} option ...").ConfigureAwait(false)) { // Resolve the project in the current directory. - var workingDirectory = Directory.GetCurrentDirectory(); - var projects = Directory.GetFiles(workingDirectory, "*.csproj", SearchOption.TopDirectoryOnly); + var csProjects = Directory.GetFiles(workingDirectory, "*.csproj", SearchOption.TopDirectoryOnly); + var vbProjects = Directory.GetFiles(workingDirectory, "*.vbproj", SearchOption.TopDirectoryOnly); - if (projects.Length == 1) + if(csProjects.Length == 1 && vbProjects.Length ==0 ) + { + projectFile = csProjects[0]; + } + else if (csProjects.Length == 0 && vbProjects.Length == 1) { - projectFile = projects[0]; + projectFile = vbProjects[0]; + this.Language = "VisualBasic"; } - else if (projects.Length == 0) + else if(csProjects.Length == 0 && vbProjects.Length == 0) { if (this.ToolContext == OperationalContext.Project) { throw new ToolArgumentException(string.Format(CultureInfo.CurrentCulture, SR.ErrInvalidOperationNoProjectFileFoundUnderFolderFormat, workingDirectory)); } } - else if (projects.Length > 1) + else { var moreThanOneProjectMsg = string.Format(CultureInfo.CurrentCulture, SR.ErrMoreThanOneProjectFoundFormat, workingDirectory); if (this.ToolContext != OperationalContext.Project) { - var projectItems = projects.Aggregate((projectMsg, projectItem) => $"{projectMsg}, {projectItem}").Trim(',').Trim(); + var projectItems = csProjects.Concat(vbProjects).ToArray().Aggregate((projectMsg, projectItem) => $"{projectMsg}, {projectItem}").Trim(',').Trim(); var useProjectOptions = string.Format(CultureInfo.CurrentCulture, SR.UseProjectFileOptionOnMultipleFilesMsgFormat, Switches.ProjectFile.Name, projectItems); throw new ToolArgumentException($"{moreThanOneProjectMsg}{Environment.NewLine}{useProjectOptions}"); } @@ -417,7 +423,7 @@ private async Task ProcessOutputFileOptionAsync(string workingDirectory, Cancell var outputFile = this.OutputFile?.OriginalPath(); if (outputFile == null) { - outputFile = "Reference.cs"; + outputFile = "Reference"; } if (!outputFile.EndsWith(this.CodeProvider.FileExtension, RuntimeEnvironmentHelper.FileStringComparison)) @@ -740,9 +746,20 @@ private void ProcessSerializerOption() private void ProcessLanguageOption() { - if (this.CodeProvider == null) + if (!string.IsNullOrEmpty(Language)) + { + try + { + CodeProvider = CodeDomProvider.CreateProvider(Language); + } + catch (Exception e) + { + throw new ToolArgumentException(string.Format(SR.ErrCouldNotCreateCodeProvider, Language, Switches.Language.Abbreviation), e); + } + } + else { - this.CodeProvider = CodeDomProvider.CreateProvider("csharp"); + CodeProvider = CodeDomProvider.CreateProvider("csharp"); } } #endregion diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.CodeDom/Configuration/CodeDomCompilationConfiguration.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.CodeDom/Configuration/CodeDomCompilationConfiguration.cs index 9d2e614704ef..445c2f737b8b 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.CodeDom/Configuration/CodeDomCompilationConfiguration.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.CodeDom/Configuration/CodeDomCompilationConfiguration.cs @@ -38,6 +38,17 @@ internal CodeDomCompilationConfiguration() compilerInfo._providerOptions = new Dictionary(); compilerInfo._providerOptions[RedistVersionInfo.NameTag] = RedistVersionInfo.DefaultVersion; AddCompilerInfo(compilerInfo); + + // VB + compilerParameters = new CompilerParameters(); + compilerParameters.WarningLevel = 4; + typeName = "Microsoft.VisualBasic.VBCodeProvider"; + compilerInfo = new CompilerInfo(compilerParameters, typeName); + compilerInfo._compilerLanguages = new string[] { "vb", "vbs", "visualbasic", "vbscript" }; + compilerInfo._compilerExtensions = new string[] { ".vb", "vb" }; + compilerInfo._providerOptions = new Dictionary(); + compilerInfo._providerOptions[RedistVersionInfo.NameTag] = RedistVersionInfo.DefaultVersion; + AddCompilerInfo(compilerInfo); } private void AddCompilerInfo(CompilerInfo compilerInfo) diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.CodeDom/Microsoft/VBCodeProvider.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.CodeDom/Microsoft/VBCodeProvider.cs new file mode 100644 index 000000000000..c1067b4b9b6f --- /dev/null +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/Microsoft.CodeDom/Microsoft/VBCodeProvider.cs @@ -0,0 +1,3584 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; +using System; +using System.IO; +using System.Collections; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Reflection; +using Microsoft.CodeDom; +using Microsoft.CodeDom.Compiler; +using System.Text; +using System.Text.RegularExpressions; +using System.Globalization; +using System.Collections.Generic; +using System.Runtime.Versioning; + + +namespace Microsoft.VisualBasic +{ + + #region class VBCodeProvider + + /// + /// [To be supplied.] + /// + public class VBCodeProvider : CodeDomProvider + { + private VBCodeGenerator _generator; + + public VBCodeProvider() + { + _generator = new VBCodeGenerator(); + } + + public VBCodeProvider(IDictionary providerOptions) + { + if (providerOptions == null) + { + throw new ArgumentNullException("providerOptions"); + } + + _generator = new VBCodeGenerator(providerOptions); + } + + /// + /// Retrieves the default extension to use when saving files using this code dom provider. + /// + public override string FileExtension + { + get + { + return "vb"; + } + } + + /// + /// Returns flags representing language variations. + /// + public override LanguageOptions LanguageOptions + { + get + { + return LanguageOptions.CaseInsensitive; + } + } + + [Obsolete("Callers should not use the ICodeGenerator interface and should instead use the methods directly on the CodeDomProvider class.")] + public override ICodeGenerator CreateGenerator() + { + return (ICodeGenerator)_generator; + } + + [Obsolete("Callers should not use the ICodeCompiler interface and should instead use the methods directly on the CodeDomProvider class.")] + public override ICodeCompiler CreateCompiler() + { + return (ICodeCompiler)_generator; + } + + /// + /// This method allows a code dom provider implementation to provide a different type converter + /// for a given data type. At design time, a designer may pass data types through this + /// method to see if the code dom provider wants to provide an additional converter. + /// A typical way this would be used is if the language this code dom provider implements + /// does not support all of the values of the MemberAttributes enumeration, or if the language + /// uses different names (Protected instead of Family, for example). The default + /// implementation just calls TypeDescriptor.GetConverter for the given type. + /// + public override TypeConverter GetConverter(Type type) + { + if (type == typeof(MemberAttributes)) + { + return VBMemberAttributeConverter.Default; + } + else if (type == typeof(TypeAttributes)) + { + return VBTypeAttributeConverter.Default; + } + + return base.GetConverter(type); + } + + public override void GenerateCodeFromMember(CodeTypeMember member, TextWriter writer, CodeGeneratorOptions options) + { + _generator.GenerateCodeFromMember(member, writer, options); + } + + } // VBCodeProvider + + #endregion class VBCodeProvider + + + #region class VBCodeGenerator + + /// + /// + /// Visual Basic 7 Code Generator. + /// + /// + internal class VBCodeGenerator : CodeCompiler + { + private const int MaxLineLength = 80; + + private const GeneratorSupport LanguageSupport = GeneratorSupport.EntryPointMethod | + GeneratorSupport.GotoStatements | + GeneratorSupport.ArraysOfArrays | + GeneratorSupport.MultidimensionalArrays | + GeneratorSupport.StaticConstructors | + GeneratorSupport.ReturnTypeAttributes | + GeneratorSupport.AssemblyAttributes | + GeneratorSupport.TryCatchStatements | + GeneratorSupport.DeclareValueTypes | + GeneratorSupport.DeclareEnums | + GeneratorSupport.DeclareEvents | + GeneratorSupport.DeclareDelegates | + GeneratorSupport.DeclareInterfaces | + GeneratorSupport.ParameterAttributes | + GeneratorSupport.ReferenceParameters | + GeneratorSupport.ChainedConstructorArguments | + GeneratorSupport.NestedTypes | + GeneratorSupport.MultipleInterfaceMembers | + GeneratorSupport.PublicStaticMembers | + GeneratorSupport.ComplexExpressions | + GeneratorSupport.Win32Resources | + GeneratorSupport.Resources | + GeneratorSupport.PartialTypes | + GeneratorSupport.GenericTypeReference | + GeneratorSupport.GenericTypeDeclaration | + GeneratorSupport.DeclareIndexerProperties; + + private static volatile Regex s_outputReg; + + private int _statementDepth = 0; + private IDictionary _provOptions; + + // This is the keyword list. To minimize search time and startup time, this is stored by length + // and then alphabetically for use by FixedStringLookup.Contains. + private static readonly string[][] s_keywords = new string[][] { + null, // 1 character + new string[] { // 2 characters + "as", + "do", + "if", + "in", + "is", + "me", + "of", + "on", + "or", + "to", + }, + new string[] { // 3 characters + "and", + "dim", + "end", + "for", + "get", + "let", + "lib", + "mod", + "new", + "not", + "rem", + "set", + "sub", + "try", + "xor", + }, + new string[] { // 4 characters + "ansi", + "auto", + "byte", + "call", + "case", + "cdbl", + "cdec", + "char", + "cint", + "clng", + "cobj", + "csng", + "cstr", + "date", + "each", + "else", + "enum", + "exit", + "goto", + "like", + "long", + "loop", + "next", + "step", + "stop", + "then", + "true", + "wend", + "when", + "with", + }, + new string[] { // 5 characters + "alias", + "byref", + "byval", + "catch", + "cbool", + "cbyte", + "cchar", + "cdate", + "class", + "const", + "ctype", + "cuint", + "culng", + "endif", + "erase", + "error", + "event", + "false", + "gosub", + "isnot", + "redim", + "sbyte", + "short", + "throw", + "ulong", + "until", + "using", + "while", + }, + new string[] { // 6 characters + "csbyte", + "cshort", + "double", + "elseif", + "friend", + "global", + "module", + "mybase", + "object", + "option", + "orelse", + "public", + "resume", + "return", + "select", + "shared", + "single", + "static", + "string", + "typeof", + "ushort", + }, + new string[] { // 7 characters + "andalso", + "boolean", + "cushort", + "decimal", + "declare", + "default", + "finally", + "gettype", + "handles", + "imports", + "integer", + "myclass", + "nothing", + "partial", + "private", + "shadows", + "trycast", + "unicode", + "variant", + }, + new string[] { // 8 characters + "assembly", + "continue", + "delegate", + "function", + "inherits", + "operator", + "optional", + "preserve", + "property", + "readonly", + "synclock", + "uinteger", + "widening" + }, + new string [] { // 9 characters + "addressof", + "interface", + "namespace", + "narrowing", + "overloads", + "overrides", + "protected", + "structure", + "writeonly", + }, + new string [] { // 10 characters + "addhandler", + "directcast", + "implements", + "paramarray", + "raiseevent", + "withevents", + }, + new string[] { // 11 characters + "mustinherit", + "overridable", + }, + new string[] { // 12 characters + "mustoverride", + }, + new string [] { // 13 characters + "removehandler", + }, + // class_finalize and class_initialize are not keywords anymore, + // but it will be nice to escape them to avoid warning + new string [] { // 14 characters + "class_finalize", + "notinheritable", + "notoverridable", + }, + null, // 15 characters + new string [] { + "class_initialize", + } + }; + + internal VBCodeGenerator() + { + } + + internal VBCodeGenerator(IDictionary providerOptions) + { + _provOptions = providerOptions; + } + + +#if DEBUG + static VBCodeGenerator() + { + FixedStringLookup.VerifyLookupTable(s_keywords, true); + + // Sanity check: try some values; + Debug.Assert(IsKeyword("for")); + Debug.Assert(IsKeyword("foR")); + Debug.Assert(IsKeyword("cdec")); + Debug.Assert(!IsKeyword("cdab")); + Debug.Assert(!IsKeyword("cdum")); + } +#endif + + /// + /// + /// Gets or the file extension to use for source files. + /// + /// + protected override string FileExtension { get { return ".vb"; } } + + /// + /// + /// Gets the name of the compiler exe + /// + /// + protected override string CompilerName { get { return "vbc.exe"; } } + + /// + /// + /// Tells whether or not the current class should be generated as a module + /// + /// + private bool IsCurrentModule + { + get + { + return (IsCurrentClass && GetUserData(CurrentClass, "Module", false)); + } + } + + /// + /// + /// Gets the token that is used to represent . + /// + /// + protected override string NullToken + { + get + { + return "Nothing"; + } + } + + private void EnsureInDoubleQuotes(ref bool fInDoubleQuotes, StringBuilder b) + { + if (fInDoubleQuotes) return; + b.Append("&\""); + fInDoubleQuotes = true; + } + + private void EnsureNotInDoubleQuotes(ref bool fInDoubleQuotes, StringBuilder b) + { + if (!fInDoubleQuotes) return; + b.Append("\""); + fInDoubleQuotes = false; + } + + /// + /// + /// Provides conversion to formatting with escape codes. + /// + /// + protected override string QuoteSnippetString(string value) + { + StringBuilder b = new StringBuilder(value.Length + 5); + + bool fInDoubleQuotes = true; + Indentation indentObj = new Indentation((IndentedTextWriter)Output, Indent + 1); + + b.Append("\""); + + int i = 0; + while (i < value.Length) + { + char ch = value[i]; + switch (ch) + { + case '\"': + // These are the inward sloping quotes used by default in some cultures like CHS. + // VBC.EXE does a mapping ANSI that results in it treating these as syntactically equivalent to a + // regular double quote. + case '\u201C': + case '\u201D': + case '\uFF02': + EnsureInDoubleQuotes(ref fInDoubleQuotes, b); + b.Append(ch); + b.Append(ch); + break; + case '\r': + EnsureNotInDoubleQuotes(ref fInDoubleQuotes, b); + if (i < value.Length - 1 && value[i + 1] == '\n') + { + b.Append("&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)"); + i++; + } + else + { + b.Append("&Global.Microsoft.VisualBasic.ChrW(13)"); + } + break; + case '\t': + EnsureNotInDoubleQuotes(ref fInDoubleQuotes, b); + b.Append("&Global.Microsoft.VisualBasic.ChrW(9)"); + break; + case '\0': + EnsureNotInDoubleQuotes(ref fInDoubleQuotes, b); + b.Append("&Global.Microsoft.VisualBasic.ChrW(0)"); + break; + case '\n': + EnsureNotInDoubleQuotes(ref fInDoubleQuotes, b); + b.Append("&Global.Microsoft.VisualBasic.ChrW(10)"); + break; + case '\u2028': + case '\u2029': + EnsureNotInDoubleQuotes(ref fInDoubleQuotes, b); + AppendEscapedChar(b, ch); + break; + default: + EnsureInDoubleQuotes(ref fInDoubleQuotes, b); + b.Append(value[i]); + break; + } + + if (i > 0 && i % MaxLineLength == 0) + { + // + // If current character is a high surrogate and the following + // character is a low surrogate, don't break them. + // Otherwise when we write the string to a file, we might lose + // the characters. + // + if (Char.IsHighSurrogate(value[i]) + && (i < value.Length - 1) + && Char.IsLowSurrogate(value[i + 1])) + { + b.Append(value[++i]); + } + + if (fInDoubleQuotes) + b.Append("\""); + fInDoubleQuotes = true; + + b.Append("& _ "); + b.Append(Environment.NewLine); + b.Append(indentObj.IndentationString); + b.Append('\"'); + } + ++i; + } + + if (fInDoubleQuotes) + b.Append("\""); + + return b.ToString(); + } + + //@TODO: Someday emit the hex version to be consistent with C#. + private static void AppendEscapedChar(StringBuilder b, char value) + { + b.Append("&Global.Microsoft.VisualBasic.ChrW("); + b.Append(((int)value).ToString(CultureInfo.InvariantCulture)); + b.Append(")"); + } + + protected override void ProcessCompilerOutputLine(CompilerResults results, string line) + { + if (s_outputReg == null) + { + s_outputReg = new Regex(@"^([^(]*)\(?([0-9]*)\)? ?:? ?(error|warning) ([A-Z]+[0-9]+) ?: ((.|\n)*)"); + } + Match m = s_outputReg.Match(line); + if (m.Success) + { + CompilerError ce = new CompilerError(); + ce.FileName = m.Groups[1].Value; + string rawLine = m.Groups[2].Value; + if (rawLine != null && rawLine.Length > 0) + { + ce.Line = int.Parse(rawLine, CultureInfo.InvariantCulture); + } + if (string.Compare(m.Groups[3].Value, "warning", StringComparison.OrdinalIgnoreCase) == 0) + { + ce.IsWarning = true; + } + ce.ErrorNumber = m.Groups[4].Value; + ce.ErrorText = m.Groups[5].Value; + results.Errors.Add(ce); + } + } + + protected override string CmdArgsFromParameters(CompilerParameters options) + { + // The VB Compiler throws an error if an empty string is specified as an assembly reference. + foreach (string s in options.ReferencedAssemblies) + { + if (String.IsNullOrEmpty(s)) + { + throw new ArgumentException("SRCodeDom.NullOrEmpty_Value_in_Property" + "ReferencedAssemblies", "options"); + } + } + + StringBuilder sb = new StringBuilder(128); + if (options.GenerateExecutable) + { + sb.Append("/t:exe "); + if (options.MainClass != null && options.MainClass.Length > 0) + { + sb.Append("/main:"); + sb.Append(options.MainClass); + sb.Append(" "); + } + } + else + { + sb.Append("/t:library "); + } + + // Get UTF8 output from the compiler + sb.Append("/utf8output "); + + string coreAssemblyFileName = options.CoreAssemblyFileName; + + if (!String.IsNullOrWhiteSpace(coreAssemblyFileName)) + { + string asmblFilePath = coreAssemblyFileName.Trim(); + string asmblFileDir = Path.GetDirectoryName(asmblFilePath); + + sb.Append("/nostdlib "); + sb.Append("/sdkpath:\"").Append(asmblFileDir).Append("\" "); + sb.Append("/R:\"").Append(asmblFilePath).Append("\" "); + } + + foreach (string s in options.ReferencedAssemblies) + { + // Ignore any Microsoft.VisualBasic.dll, since Visual Basic implies it (bug 72785) + string fileName = Path.GetFileName(s); + if (string.Compare(fileName, "Microsoft.VisualBasic.dll", StringComparison.OrdinalIgnoreCase) == 0) + continue; + + // Same deal for mscorlib (bug ASURT 81568) + if (string.Compare(fileName, "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0) + continue; + + sb.Append("/R:"); + sb.Append("\""); + sb.Append(s); + sb.Append("\""); + sb.Append(" "); + } + + sb.Append("/out:"); + sb.Append("\""); + sb.Append(options.OutputAssembly); + sb.Append("\""); + sb.Append(" "); + + if (options.IncludeDebugInformation) + { + sb.Append("/D:DEBUG=1 "); + sb.Append("/debug+ "); + } + else + { + sb.Append("/debug- "); + } + + if (options.Win32Resource != null) + { + sb.Append("/win32resource:\"" + options.Win32Resource + "\" "); + } + + foreach (string s in options.EmbeddedResources) + { + sb.Append("/res:\""); + sb.Append(s); + sb.Append("\" "); + } + + foreach (string s in options.LinkedResources) + { + sb.Append("/linkres:\""); + sb.Append(s); + sb.Append("\" "); + } + + if (options.TreatWarningsAsErrors) + { + sb.Append("/warnaserror+ "); + } + + if (options.CompilerOptions != null) + { + sb.Append(options.CompilerOptions + " "); + } + + return sb.ToString(); + } + + protected override void OutputAttributeArgument(CodeAttributeArgument arg) + { + if (arg.Name != null && arg.Name.Length > 0) + { + OutputIdentifier(arg.Name); + Output.Write(":="); + } + ((ICodeGenerator)this).GenerateCodeFromExpression(arg.Value, ((IndentedTextWriter)Output).InnerWriter, Options); + } + + private void OutputAttributes(CodeAttributeDeclarationCollection attributes, bool inLine) + { + OutputAttributes(attributes, inLine, null, false); + } + + private void OutputAttributes(CodeAttributeDeclarationCollection attributes, bool inLine, string prefix, bool closingLine) + { + if (attributes.Count == 0) return; + IEnumerator en = attributes.GetEnumerator(); + bool firstAttr = true; + GenerateAttributeDeclarationsStart(attributes); + while (en.MoveNext()) + { + + if (firstAttr) + { + firstAttr = false; + } + else + { + Output.Write(", "); + if (!inLine) + { + ContinueOnNewLine(""); + Output.Write(" "); + } + } + + if (prefix != null && prefix.Length > 0) + { + Output.Write(prefix); + } + + CodeAttributeDeclaration current = (CodeAttributeDeclaration)en.Current; + + if (current.AttributeType != null) + { + Output.Write(GetTypeOutput(current.AttributeType)); + } + Output.Write("("); + + bool firstArg = true; + foreach (CodeAttributeArgument arg in current.Arguments) + { + if (firstArg) + { + firstArg = false; + } + else + { + Output.Write(", "); + } + + OutputAttributeArgument(arg); + } + + Output.Write(")"); + + } + GenerateAttributeDeclarationsEnd(attributes); + Output.Write(" "); + if (!inLine) + { + if (closingLine) + { + Output.WriteLine(); + } + else + { + ContinueOnNewLine(""); + } + } + } + + protected override void OutputDirection(FieldDirection dir) + { + switch (dir) + { + case FieldDirection.In: + Output.Write("ByVal "); + break; + case FieldDirection.Out: + case FieldDirection.Ref: + Output.Write("ByRef "); + break; + } + } + + protected override void GenerateDefaultValueExpression(CodeDefaultValueExpression e) + { + Output.Write("CType(Nothing, " + GetTypeOutput(e.Type) + ")"); + } + + protected override void GenerateDirectionExpression(CodeDirectionExpression e) + { + // Visual Basic does not need to adorn the calling point with a direction, so just output the expression. + GenerateExpression(e.Expression); + } + + protected override void OutputFieldScopeModifier(MemberAttributes attributes) + { + switch (attributes & MemberAttributes.ScopeMask) + { + case MemberAttributes.Final: + Output.Write(""); + break; + case MemberAttributes.Static: + // ignore Static for fields in a Module since all fields in a module are already + // static and it is a syntax error to explicitly mark them as static + // + if (!IsCurrentModule) + { + Output.Write("Shared "); + } + break; + case MemberAttributes.Const: + Output.Write("Const "); + break; + default: + Output.Write(""); + break; + } + } + + /// + /// + /// Generates code for the specified CodeDom based member + /// access modifier representation. + /// + /// + protected override void OutputMemberAccessModifier(MemberAttributes attributes) + { + switch (attributes & MemberAttributes.AccessMask) + { + case MemberAttributes.Assembly: + Output.Write("Friend "); + break; + case MemberAttributes.FamilyAndAssembly: + Output.Write("Friend "); + break; + case MemberAttributes.Family: + Output.Write("Protected "); + break; + case MemberAttributes.FamilyOrAssembly: + Output.Write("Protected Friend "); + break; + case MemberAttributes.Private: + Output.Write("Private "); + break; + case MemberAttributes.Public: + Output.Write("Public "); + break; + } + } + + private void OutputVTableModifier(MemberAttributes attributes) + { + switch (attributes & MemberAttributes.VTableMask) + { + case MemberAttributes.New: + Output.Write("Shadows "); + break; + } + } + + /// + /// + /// Generates code for the specified CodeDom based member scope modifier + /// representation. + /// + /// + protected override void OutputMemberScopeModifier(MemberAttributes attributes) + { + + switch (attributes & MemberAttributes.ScopeMask) + { + case MemberAttributes.Abstract: + Output.Write("MustOverride "); + break; + case MemberAttributes.Final: + Output.Write(""); + break; + case MemberAttributes.Static: + // ignore Static for members in a Module since all members in a module are already + // static and it is a syntax error to explicitly mark them as static + // + if (!IsCurrentModule) + { + Output.Write("Shared "); + } + break; + case MemberAttributes.Override: + Output.Write("Overrides "); + break; + case MemberAttributes.Private: + Output.Write("Private "); + break; + default: + switch (attributes & MemberAttributes.AccessMask) + { + case MemberAttributes.Family: + case MemberAttributes.Public: + case MemberAttributes.Assembly: + Output.Write("Overridable "); + break; + default: + // nothing; + break; + } + break; + } + } + + /// + /// + /// Generates code for the specified CodeDom based operator + /// representation. + /// + /// + protected override void OutputOperator(CodeBinaryOperatorType op) + { + switch (op) + { + case CodeBinaryOperatorType.IdentityInequality: + Output.Write("<>"); + break; + case CodeBinaryOperatorType.IdentityEquality: + Output.Write("Is"); + break; + case CodeBinaryOperatorType.BooleanOr: + Output.Write("OrElse"); + break; + case CodeBinaryOperatorType.BooleanAnd: + Output.Write("AndAlso"); + break; + case CodeBinaryOperatorType.ValueEquality: + Output.Write("="); + break; + case CodeBinaryOperatorType.Modulus: + Output.Write("Mod"); + break; + case CodeBinaryOperatorType.BitwiseOr: + Output.Write("Or"); + break; + case CodeBinaryOperatorType.BitwiseAnd: + Output.Write("And"); + break; + default: + base.OutputOperator(op); + break; + } + } + + private void GenerateNotIsNullExpression(CodeExpression e) + { + Output.Write("(Not ("); + GenerateExpression(e); + Output.Write(") Is "); + Output.Write(NullToken); + Output.Write(")"); + } + + protected override void GenerateBinaryOperatorExpression(CodeBinaryOperatorExpression e) + { + if (e.Operator != CodeBinaryOperatorType.IdentityInequality) + { + base.GenerateBinaryOperatorExpression(e); + return; + } + + // "o <> nothing" should be "not o is nothing" + if (e.Right is CodePrimitiveExpression && ((CodePrimitiveExpression)e.Right).Value == null) + { + GenerateNotIsNullExpression(e.Left); + return; + } + if (e.Left is CodePrimitiveExpression && ((CodePrimitiveExpression)e.Left).Value == null) + { + GenerateNotIsNullExpression(e.Right); + return; + } + + base.GenerateBinaryOperatorExpression(e); + } + + /// + /// [To be supplied.] + /// + protected override string GetResponseFileCmdArgs(CompilerParameters options, string cmdArgs) + { + + // Always specify the /noconfig flag (outside of the response file) + return "/noconfig " + base.GetResponseFileCmdArgs(options, cmdArgs); + } + + protected override void OutputIdentifier(string ident) + { + Output.Write(CreateEscapedIdentifier(ident)); + } + + /// + /// + /// Generates code for the specified CodeDom based return type + /// representation. + /// + /// + protected override void OutputType(CodeTypeReference typeRef) + { + Output.Write(GetTypeOutputWithoutArrayPostFix(typeRef)); + } + + private void OutputTypeAttributes(CodeTypeDeclaration e) + { + if ((e.Attributes & MemberAttributes.New) != 0) + { + Output.Write("Shadows "); + } + + TypeAttributes attributes = e.TypeAttributes; + + if (e.IsPartial) + { + Output.Write("Partial "); + } + + switch (attributes & TypeAttributes.VisibilityMask) + { + case TypeAttributes.Public: + case TypeAttributes.NestedPublic: + Output.Write("Public "); + break; + case TypeAttributes.NestedPrivate: + Output.Write("Private "); + break; + + case TypeAttributes.NestedFamily: + Output.Write("Protected "); + break; + case TypeAttributes.NotPublic: + case TypeAttributes.NestedAssembly: + case TypeAttributes.NestedFamANDAssem: + Output.Write("Friend "); + break; + case TypeAttributes.NestedFamORAssem: + Output.Write("Protected Friend "); + break; + } + + if (e.IsStruct) + { + Output.Write("Structure "); + } + else if (e.IsEnum) + { + Output.Write("Enum "); + } + else + { + switch (attributes & TypeAttributes.ClassSemanticsMask) + { + case TypeAttributes.Class: + // if this "class" should generate as a module, then don't check + // inheritance flags since modules can't inherit + if (IsCurrentModule) + { + Output.Write("Module "); + } + else + { + if ((attributes & TypeAttributes.Sealed) == TypeAttributes.Sealed) + { + Output.Write("NotInheritable "); + } + if ((attributes & TypeAttributes.Abstract) == TypeAttributes.Abstract) + { + Output.Write("MustInherit "); + } + Output.Write("Class "); + } + break; + case TypeAttributes.Interface: + Output.Write("Interface "); + break; + } + } + } + + /// + /// + /// Generates code for the specified CodeDom based type name pair + /// representation. + /// + /// + protected override void OutputTypeNamePair(CodeTypeReference typeRef, string name) + { + if (string.IsNullOrEmpty(name)) + name = "__exception"; + + OutputIdentifier(name); + OutputArrayPostfix(typeRef); + Output.Write(" As "); + OutputType(typeRef); + } + + private string GetArrayPostfix(CodeTypeReference typeRef) + { + string s = ""; + if (typeRef.ArrayElementType != null) + { + // Recurse up + s = GetArrayPostfix(typeRef.ArrayElementType); + } + + if (typeRef.ArrayRank > 0) + { + char[] results = new char[typeRef.ArrayRank + 1]; + results[0] = '('; + results[typeRef.ArrayRank] = ')'; + for (int i = 1; i < typeRef.ArrayRank; i++) + { + results[i] = ','; + } + s = new string(results) + s; + } + + return s; + } + + private void OutputArrayPostfix(CodeTypeReference typeRef) + { + if (typeRef.ArrayRank > 0) + { + Output.Write(GetArrayPostfix(typeRef)); + } + } + + /// + /// + /// Generates code for the specified CodeDom based for loop statement + /// representation. + /// + /// + protected override void GenerateIterationStatement(CodeIterationStatement e) + { + GenerateStatement(e.InitStatement); + Output.Write("Do While "); + GenerateExpression(e.TestExpression); + Output.WriteLine(""); + Indent++; + GenerateVBStatements(e.Statements); + GenerateStatement(e.IncrementStatement); + Indent--; + Output.WriteLine("Loop"); + } + + /// + /// + /// Generates code for the specified CodeDom based primitive expression + /// representation. + /// + /// + protected override void GeneratePrimitiveExpression(CodePrimitiveExpression e) + { + if (e.Value is char) + { + Output.Write("Global.Microsoft.VisualBasic.ChrW(" + ((IConvertible)e.Value).ToInt32(CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture) + ")"); + } + else if (e.Value is SByte) + { + Output.Write("CSByte("); + Output.Write(((SByte)e.Value).ToString(CultureInfo.InvariantCulture)); + Output.Write(")"); + } + else if (e.Value is UInt16) + { + Output.Write(((UInt16)e.Value).ToString(CultureInfo.InvariantCulture)); + Output.Write("US"); + } + else if (e.Value is UInt32) + { + Output.Write(((UInt32)e.Value).ToString(CultureInfo.InvariantCulture)); + Output.Write("UI"); + } + else if (e.Value is UInt64) + { + Output.Write(((UInt64)e.Value).ToString(CultureInfo.InvariantCulture)); + Output.Write("UL"); + } + else + { + base.GeneratePrimitiveExpression(e); + } + } + + /// + /// + /// Generates code for the specified CodeDom based throw exception statement + /// representation. + /// + /// + protected override void GenerateThrowExceptionStatement(CodeThrowExceptionStatement e) + { + Output.Write("Throw"); + if (e.ToThrow != null) + { + Output.Write(" "); + GenerateExpression(e.ToThrow); + } + Output.WriteLine(""); + } + + /// + /// + /// Generates code for the specified CodeDom based array creation expression + /// representation. + /// + /// + protected override void GenerateArrayCreateExpression(CodeArrayCreateExpression e) + { + Output.Write("New "); + + CodeExpressionCollection init = e.Initializers; + if (init.Count > 0) + { + String typeName = GetTypeOutput(e.CreateType); + Output.Write(typeName); + + // TODO: this is a hack to generate array if user doesn't + // specify a array type. Should be removed sometime. + if (typeName.IndexOf('(') == -1) + { + Output.Write("()"); + } + + Output.Write(" {"); + Indent++; + OutputExpressionList(init); + Indent--; + Output.Write("}"); + } + else + { + String typeName = GetTypeOutput(e.CreateType); + + int index = typeName.IndexOf('('); + if (index == -1) + { + // TODO: this is a hack to generate array if user doesn't + // specify a array type. Should be removed sometime. + Output.Write(typeName); + Output.Write('('); + } + else + { + Output.Write(typeName.Substring(0, index + 1)); + } + + // The tricky thing is we need to declare the size - 1 + if (e.SizeExpression != null) + { + Output.Write("("); + GenerateExpression(e.SizeExpression); + Output.Write(") - 1"); + } + else + { + Output.Write(e.Size - 1); + } + + if (index == -1) + { + Output.Write(')'); + } + else + { + Output.Write(typeName.Substring(index + 1)); + } + + Output.Write(" {}"); + } + } + + /// + /// + /// Generates code for the specified CodeDom based base reference expression + /// representation. + /// + /// + protected override void GenerateBaseReferenceExpression(CodeBaseReferenceExpression e) + { + Output.Write("MyBase"); + } + + /// + /// + /// Generates code for the specified CodeDom based cast expression representation. + /// + /// + protected override void GenerateCastExpression(CodeCastExpression e) + { + Output.Write("CType("); + GenerateExpression(e.Expression); + Output.Write(","); + OutputType(e.TargetType); + OutputArrayPostfix(e.TargetType); + Output.Write(")"); + } + + /// + /// + /// Generates code for the specified CodeDom based delegate creation expression + /// representation. + /// + /// + protected override void GenerateDelegateCreateExpression(CodeDelegateCreateExpression e) + { + Output.Write("AddressOf "); + GenerateExpression(e.TargetObject); + Output.Write("."); + OutputIdentifier(e.MethodName); + } + + /// + /// + /// Generates code for the specified CodeDom based field reference expression + /// representation. + /// + /// + protected override void GenerateFieldReferenceExpression(CodeFieldReferenceExpression e) + { + + if (e.TargetObject != null) + { + GenerateExpression(e.TargetObject); + Output.Write("."); + } + + OutputIdentifier(e.FieldName); + } + + protected override void GenerateSingleFloatValue(Single s) + { + if (float.IsNaN(s)) + { + Output.Write("Single.NaN"); + } + else if (float.IsNegativeInfinity(s)) + { + Output.Write("Single.NegativeInfinity"); + } + else if (float.IsPositiveInfinity(s)) + { + Output.Write("Single.PositiveInfinity"); + } + else + { + Output.Write(s.ToString(CultureInfo.InvariantCulture)); + Output.Write('!'); + } + } + + protected override void GenerateDoubleValue(double d) + { + if (double.IsNaN(d)) + { + Output.Write("Double.NaN"); + } + else if (double.IsNegativeInfinity(d)) + { + Output.Write("Double.NegativeInfinity"); + } + else if (double.IsPositiveInfinity(d)) + { + Output.Write("Double.PositiveInfinity"); + } + else + { + Output.Write(d.ToString("R", CultureInfo.InvariantCulture)); + // always mark a double as being a double in case we have no decimal portion (e.g write 1D instead of 1 which is an int) + Output.Write("R"); + } + } + + protected override void GenerateDecimalValue(Decimal d) + { + Output.Write(d.ToString(CultureInfo.InvariantCulture)); + Output.Write('D'); + } + + protected override void GenerateArgumentReferenceExpression(CodeArgumentReferenceExpression e) + { + OutputIdentifier(e.ParameterName); + } + + protected override void GenerateVariableReferenceExpression(CodeVariableReferenceExpression e) + { + OutputIdentifier(e.VariableName); + } + + /// + /// + /// Generates code for the specified CodeDom based indexer expression + /// representation. + /// + /// + protected override void GenerateIndexerExpression(CodeIndexerExpression e) + { + GenerateExpression(e.TargetObject); + // If this IndexerExpression is referencing to base, we need to emit + // .Item after MyBase. Otherwise the code won't compile. + if (e.TargetObject is CodeBaseReferenceExpression) + { + Output.Write(".Item"); + } + + + Output.Write("("); + bool first = true; + foreach (CodeExpression exp in e.Indices) + { + if (first) + { + first = false; + } + else + { + Output.Write(", "); + } + GenerateExpression(exp); + } + Output.Write(")"); + + } + + protected override void GenerateArrayIndexerExpression(CodeArrayIndexerExpression e) + { + GenerateExpression(e.TargetObject); + Output.Write("("); + bool first = true; + foreach (CodeExpression exp in e.Indices) + { + if (first) + { + first = false; + } + else + { + Output.Write(", "); + } + GenerateExpression(exp); + } + Output.Write(")"); + + } + + /// + /// + /// Generates code for the specified CodeDom based code snippet expression + /// representation. + /// + /// + protected override void GenerateSnippetExpression(CodeSnippetExpression e) + { + Output.Write(e.Value); + } + /// + /// + /// Generates code for the specified CodeDom based method invoke + /// expression. + /// + /// + protected override void GenerateMethodInvokeExpression(CodeMethodInvokeExpression e) + { + GenerateMethodReferenceExpression(e.Method); + CodeExpressionCollection parameters = e.Parameters; + if (parameters.Count > 0) + { + Output.Write("("); + OutputExpressionList(e.Parameters); + Output.Write(")"); + } + } + + protected override void GenerateMethodReferenceExpression(CodeMethodReferenceExpression e) + { + if (e.TargetObject != null) + { + GenerateExpression(e.TargetObject); + Output.Write("."); + Output.Write(e.MethodName); + } + else + { + OutputIdentifier(e.MethodName); + } + + if (e.TypeArguments.Count > 0) + { + Output.Write(GetTypeArgumentsOutput(e.TypeArguments)); + } + } + + protected override void GenerateEventReferenceExpression(CodeEventReferenceExpression e) + { + if (e.TargetObject != null) + { + bool localReference = (e.TargetObject is CodeThisReferenceExpression); + GenerateExpression(e.TargetObject); + Output.Write("."); + if (localReference) + { + Output.Write(e.EventName + "Event"); + } + else + { + Output.Write(e.EventName); + } + } + else + { + OutputIdentifier(e.EventName + "Event"); + } + } + + private void GenerateFormalEventReferenceExpression(CodeEventReferenceExpression e) + { + if (e.TargetObject != null) + { + // Visual Basic Compiler does not like the me reference like this. + if (!(e.TargetObject is CodeThisReferenceExpression)) + { + GenerateExpression(e.TargetObject); + Output.Write("."); + } + } + OutputIdentifier(e.EventName); + } + + + /// + /// + /// Generates code for the specified CodeDom based delegate invoke + /// expression. + /// + /// + protected override void GenerateDelegateInvokeExpression(CodeDelegateInvokeExpression e) + { + if (e.TargetObject != null) + { + if (e.TargetObject is CodeEventReferenceExpression) + { + Output.Write("RaiseEvent "); + GenerateFormalEventReferenceExpression((CodeEventReferenceExpression)e.TargetObject); + } + else + { + GenerateExpression(e.TargetObject); + } + } + + CodeExpressionCollection parameters = e.Parameters; + if (parameters.Count > 0) + { + Output.Write("("); + OutputExpressionList(e.Parameters); + Output.Write(")"); + } + } + + /// + /// + /// Generates code for the specified CodeDom based object creation + /// expression. + /// + /// + protected override void GenerateObjectCreateExpression(CodeObjectCreateExpression e) + { + Output.Write("New "); + OutputType(e.CreateType); + // always write out the () to disambiguate cases like "New System.Random().Next(x,y)" + Output.Write("("); + OutputExpressionList(e.Parameters); + Output.Write(")"); + } + + /// + /// + /// Generates code for the specified CodeDom + /// based parameter declaration expression representation. + /// + /// + protected override void GenerateParameterDeclarationExpression(CodeParameterDeclarationExpression e) + { + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, true); + } + OutputDirection(e.Direction); + OutputTypeNamePair(e.Type, e.Name); + } + + protected override void GeneratePropertySetValueReferenceExpression(CodePropertySetValueReferenceExpression e) + { + Output.Write("value"); + } + + /// + /// + /// Generates code for the specified CodeDom based this reference expression + /// representation. + /// + /// + protected override void GenerateThisReferenceExpression(CodeThisReferenceExpression e) + { + Output.Write("Me"); + } + + /// + /// + /// Generates code for the specified CodeDom based method invoke statement + /// representation. + /// + /// + protected override void GenerateExpressionStatement(CodeExpressionStatement e) + { + GenerateExpression(e.Expression); + Output.WriteLine(""); + } + + /// + /// + /// Tells whether or not the given comment is a DocComment + /// + /// + private bool IsDocComment(CodeCommentStatement comment) + { + + return ((comment != null) && (comment.Comment != null) && comment.Comment.DocComment); + } + + /// + /// + /// Overridden in order to output XML DocComments in the correct order for VB + /// + protected override void GenerateCommentStatements(CodeCommentStatementCollection e) + { + + // since the compiler emits a warning if XML DocComment blocks appear before + // normal comments, we need to output non-DocComments first, followed by + // DocComments. + // + foreach (CodeCommentStatement comment in e) + { + if (!IsDocComment(comment)) + { + GenerateCommentStatement(comment); + } + } + + foreach (CodeCommentStatement comment in e) + { + if (IsDocComment(comment)) + { + GenerateCommentStatement(comment); + } + } + } + + protected override void GenerateComment(CodeComment e) + { + String commentLineStart = e.DocComment ? "'''" : "'"; + Output.Write(commentLineStart); + string value = e.Text; + for (int i = 0; i < value.Length; i++) + { + Output.Write(value[i]); + + if (value[i] == '\r') + { + if (i < value.Length - 1 && value[i + 1] == '\n') + { // if next char is '\n', skip it + Output.Write('\n'); + i++; + } + ((IndentedTextWriter)Output).InternalOutputTabs(); + Output.Write(commentLineStart); + } + else if (value[i] == '\n') + { + ((IndentedTextWriter)Output).InternalOutputTabs(); + Output.Write(commentLineStart); + } + else if (value[i] == '\u2028' || value[i] == '\u2029' || value[i] == '\u0085') + { + Output.Write(commentLineStart); + } + } + Output.WriteLine(); + } + + /// + /// + /// Generates code for the specified CodeDom based method return statement + /// representation. + /// + /// + protected override void GenerateMethodReturnStatement(CodeMethodReturnStatement e) + { + if (e.Expression != null) + { + Output.Write("Return "); + GenerateExpression(e.Expression); + Output.WriteLine(""); + } + else + { + Output.WriteLine("Return"); + } + } + + /// + /// + /// Generates code for the specified CodeDom based if statement representation. + /// + /// + protected override void GenerateConditionStatement(CodeConditionStatement e) + { + Output.Write("If "); + GenerateExpression(e.Condition); + Output.WriteLine(" Then"); + Indent++; + GenerateVBStatements(e.TrueStatements); + Indent--; + + CodeStatementCollection falseStatemetns = e.FalseStatements; + if (falseStatemetns.Count > 0) + { + Output.Write("Else"); + Output.WriteLine(""); + Indent++; + GenerateVBStatements(e.FalseStatements); + Indent--; + } + Output.WriteLine("End If"); + } + + /// + /// + /// Generates code for the specified CodeDom based try catch finally statement + /// representation. + /// + /// + protected override void GenerateTryCatchFinallyStatement(CodeTryCatchFinallyStatement e) + { + Output.WriteLine("Try "); + Indent++; + GenerateVBStatements(e.TryStatements); + Indent--; + CodeCatchClauseCollection catches = e.CatchClauses; + if (catches.Count > 0) + { + IEnumerator en = catches.GetEnumerator(); + while (en.MoveNext()) + { + CodeCatchClause current = (CodeCatchClause)en.Current; + Output.Write("Catch "); + OutputTypeNamePair(current.CatchExceptionType, current.LocalName); + Output.WriteLine(""); + Indent++; + GenerateVBStatements(current.Statements); + Indent--; + } + } + + CodeStatementCollection finallyStatements = e.FinallyStatements; + if (finallyStatements.Count > 0) + { + Output.WriteLine("Finally"); + Indent++; + GenerateVBStatements(finallyStatements); + Indent--; + } + Output.WriteLine("End Try"); + } + + /// + /// + /// Generates code for the specified CodeDom based assignment statement + /// representation. + /// + /// + protected override void GenerateAssignStatement(CodeAssignStatement e) + { + GenerateExpression(e.Left); + Output.Write(" = "); + GenerateExpression(e.Right); + Output.WriteLine(""); + } + + protected override void GenerateAttachEventStatement(CodeAttachEventStatement e) + { + Output.Write("AddHandler "); + GenerateFormalEventReferenceExpression(e.Event); + Output.Write(", "); + GenerateExpression(e.Listener); + Output.WriteLine(""); + } + + protected override void GenerateRemoveEventStatement(CodeRemoveEventStatement e) + { + Output.Write("RemoveHandler "); + GenerateFormalEventReferenceExpression(e.Event); + Output.Write(", "); + GenerateExpression(e.Listener); + Output.WriteLine(""); + } + + protected override void GenerateSnippetStatement(CodeSnippetStatement e) + { + Output.WriteLine(e.Value); + } + + protected override void GenerateGotoStatement(CodeGotoStatement e) + { + Output.Write("goto "); + Output.WriteLine(e.Label); + } + + protected override void GenerateLabeledStatement(CodeLabeledStatement e) + { + Indent--; + Output.Write(e.Label); + Output.WriteLine(":"); + Indent++; + if (e.Statement != null) + { + GenerateStatement(e.Statement); + } + } + + /// + /// + /// Generates code for the specified CodeDom variable declaration statement + /// representation. + /// + /// + protected override void GenerateVariableDeclarationStatement(CodeVariableDeclarationStatement e) + { + bool doInit = true; + + Output.Write("Dim "); + + CodeTypeReference typeRef = e.Type; + if (typeRef.ArrayRank == 1 && e.InitExpression != null) + { + CodeArrayCreateExpression eAsArrayCreate = e.InitExpression as CodeArrayCreateExpression; + if (eAsArrayCreate != null && eAsArrayCreate.Initializers.Count == 0) + { + doInit = false; + OutputIdentifier(e.Name); + Output.Write("("); + + if (eAsArrayCreate.SizeExpression != null) + { + Output.Write("("); + GenerateExpression(eAsArrayCreate.SizeExpression); + Output.Write(") - 1"); + } + else + { + Output.Write(eAsArrayCreate.Size - 1); + } + + Output.Write(")"); + + if (typeRef.ArrayElementType != null) + OutputArrayPostfix(typeRef.ArrayElementType); + + Output.Write(" As "); + OutputType(typeRef); + } + else + OutputTypeNamePair(e.Type, e.Name); + } + else + OutputTypeNamePair(e.Type, e.Name); + + if (doInit && e.InitExpression != null) + { + Output.Write(" = "); + GenerateExpression(e.InitExpression); + } + + Output.WriteLine(""); + } + /// + /// + /// Generates code for the specified CodeDom based line pragma start + /// representation. + /// + /// + protected override void GenerateLinePragmaStart(CodeLinePragma e) + { + Output.WriteLine(""); + Output.Write("#ExternalSource(\""); + Output.Write(e.FileName); + Output.Write("\","); + Output.Write(e.LineNumber); + Output.WriteLine(")"); + } + /// + /// + /// Generates code for the specified CodeDom based line pragma end + /// representation. + /// + /// + protected override void GenerateLinePragmaEnd(CodeLinePragma e) + { + Output.WriteLine(""); + Output.WriteLine("#End ExternalSource"); + } + + + protected override void GenerateEvent(CodeMemberEvent e, CodeTypeDeclaration c) + { + if (IsCurrentDelegate || IsCurrentEnum) return; + + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + string eventName = e.Name; + if (e.PrivateImplementationType != null) + { + string impl = GetBaseTypeOutput(e.PrivateImplementationType); + impl = impl.Replace('.', '_'); + e.Name = impl + "_" + e.Name; + } + + OutputMemberAccessModifier(e.Attributes); + Output.Write("Event "); + OutputTypeNamePair(e.Type, e.Name); + + if (e.ImplementationTypes.Count > 0) + { + Output.Write(" Implements "); + bool first = true; + foreach (CodeTypeReference type in e.ImplementationTypes) + { + if (first) + { + first = false; + } + else + { + Output.Write(" , "); + } + OutputType(type); + Output.Write("."); + OutputIdentifier(eventName); + } + } + else if (e.PrivateImplementationType != null) + { + Output.Write(" Implements "); + OutputType(e.PrivateImplementationType); + Output.Write("."); + OutputIdentifier(eventName); + } + + Output.WriteLine(""); + } + + /// + /// + /// Generates code for the specified CodeDom based member + /// field representation. + /// + /// + protected override void GenerateField(CodeMemberField e) + { + if (IsCurrentDelegate || IsCurrentInterface) return; + + if (IsCurrentEnum) + { + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + OutputIdentifier(e.Name); + if (e.InitExpression != null) + { + Output.Write(" = "); + GenerateExpression(e.InitExpression); + } + Output.WriteLine(""); + } + else + { + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + OutputMemberAccessModifier(e.Attributes); + OutputVTableModifier(e.Attributes); + OutputFieldScopeModifier(e.Attributes); + + if (GetUserData(e, "WithEvents", false)) + { + Output.Write("WithEvents "); + } + + OutputTypeNamePair(e.Type, e.Name); + if (e.InitExpression != null) + { + Output.Write(" = "); + GenerateExpression(e.InitExpression); + } + Output.WriteLine(""); + } + } + + private bool MethodIsOverloaded(CodeMemberMethod e, CodeTypeDeclaration c) + { + if ((e.Attributes & MemberAttributes.Overloaded) != 0) + { + return true; + } + IEnumerator en = c.Members.GetEnumerator(); + while (en.MoveNext()) + { + if (!(en.Current is CodeMemberMethod)) + continue; + CodeMemberMethod meth = (CodeMemberMethod)en.Current; + + if (!(en.Current is CodeTypeConstructor) + && !(en.Current is CodeConstructor) + && meth != e + && meth.Name.Equals(e.Name, StringComparison.OrdinalIgnoreCase) + && meth.PrivateImplementationType == null) + { + return true; + } + } + + return false; + } + + /// + /// + /// Generates code for + /// the specified CodeDom based snippet member representation. + /// + /// + protected override void GenerateSnippetMember(CodeSnippetTypeMember e) + { + Output.Write(e.Text); + } + + protected override void GenerateMethod(CodeMemberMethod e, CodeTypeDeclaration c) + { + if (!(IsCurrentClass || IsCurrentStruct || IsCurrentInterface)) return; + + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + // need to change the implements name before doing overloads resolution + // + string methodName = e.Name; + if (e.PrivateImplementationType != null) + { + string impl = GetBaseTypeOutput(e.PrivateImplementationType); + impl = impl.Replace('.', '_'); + e.Name = impl + "_" + e.Name; + } + + if (!IsCurrentInterface) + { + if (e.PrivateImplementationType == null) + { + OutputMemberAccessModifier(e.Attributes); + if (MethodIsOverloaded(e, c)) + Output.Write("Overloads "); + } + OutputVTableModifier(e.Attributes); + OutputMemberScopeModifier(e.Attributes); + } + else + { + // interface may still need "Shadows" + OutputVTableModifier(e.Attributes); + } + bool sub = false; + if (e.ReturnType.BaseType.Length == 0 || string.Compare(e.ReturnType.BaseType, typeof(void).FullName, StringComparison.OrdinalIgnoreCase) == 0) + { + sub = true; + } + + if (sub) + { + Output.Write("Sub "); + } + else + { + Output.Write("Function "); + } + + + OutputIdentifier(e.Name); + OutputTypeParameters(e.TypeParameters); + + Output.Write("("); + OutputParameters(e.Parameters); + Output.Write(")"); + + if (!sub) + { + Output.Write(" As "); + if (e.ReturnTypeCustomAttributes.Count > 0) + { + OutputAttributes(e.ReturnTypeCustomAttributes, true); + } + + OutputType(e.ReturnType); + OutputArrayPostfix(e.ReturnType); + } + if (e.ImplementationTypes.Count > 0) + { + Output.Write(" Implements "); + bool first = true; + foreach (CodeTypeReference type in e.ImplementationTypes) + { + if (first) + { + first = false; + } + else + { + Output.Write(" , "); + } + OutputType(type); + Output.Write("."); + OutputIdentifier(methodName); + } + } + else if (e.PrivateImplementationType != null) + { + Output.Write(" Implements "); + OutputType(e.PrivateImplementationType); + Output.Write("."); + OutputIdentifier(methodName); + } + Output.WriteLine(""); + if (!IsCurrentInterface + && (e.Attributes & MemberAttributes.ScopeMask) != MemberAttributes.Abstract) + { + Indent++; + + GenerateVBStatements(e.Statements); + + Indent--; + if (sub) + { + Output.WriteLine("End Sub"); + } + else + { + Output.WriteLine("End Function"); + } + } + // reset the name that possibly got changed with the implements clause + e.Name = methodName; + } + + protected override void GenerateEntryPointMethod(CodeEntryPointMethod e, CodeTypeDeclaration c) + { + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + Output.WriteLine("Public Shared Sub Main()"); + Indent++; + + GenerateVBStatements(e.Statements); + + Indent--; + Output.WriteLine("End Sub"); + } + + private bool PropertyIsOverloaded(CodeMemberProperty e, CodeTypeDeclaration c) + { + if ((e.Attributes & MemberAttributes.Overloaded) != 0) + { + return true; + } + IEnumerator en = c.Members.GetEnumerator(); + while (en.MoveNext()) + { + if (!(en.Current is CodeMemberProperty)) + continue; + CodeMemberProperty prop = (CodeMemberProperty)en.Current; + if (prop != e + && prop.Name.Equals(e.Name, StringComparison.OrdinalIgnoreCase) + && prop.PrivateImplementationType == null) + { + return true; + } + } + + return false; + } + + /// + /// + /// Generates code for the specified CodeDom based member property + /// representation. + /// + /// + protected override void GenerateProperty(CodeMemberProperty e, CodeTypeDeclaration c) + { + if (!(IsCurrentClass || IsCurrentStruct || IsCurrentInterface)) return; + + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + string propName = e.Name; + if (e.PrivateImplementationType != null) + { + string impl = GetBaseTypeOutput(e.PrivateImplementationType); + impl = impl.Replace('.', '_'); + e.Name = impl + "_" + e.Name; + } + if (!IsCurrentInterface) + { + if (e.PrivateImplementationType == null) + { + OutputMemberAccessModifier(e.Attributes); + if (PropertyIsOverloaded(e, c)) + { + Output.Write("Overloads "); + } + } + OutputVTableModifier(e.Attributes); + OutputMemberScopeModifier(e.Attributes); + } + else + { + // interface may still need "Shadows" + OutputVTableModifier(e.Attributes); + } + if (e.Parameters.Count > 0 && String.Compare(e.Name, "Item", StringComparison.OrdinalIgnoreCase) == 0) + { + Output.Write("Default "); + } + if (e.HasGet) + { + if (!e.HasSet) + { + Output.Write("ReadOnly "); + } + } + else if (e.HasSet) + { + Output.Write("WriteOnly "); + } + Output.Write("Property "); + OutputIdentifier(e.Name); + Output.Write("("); + if (e.Parameters.Count > 0) + { + OutputParameters(e.Parameters); + } + Output.Write(")"); + Output.Write(" As "); + OutputType(e.Type); + OutputArrayPostfix(e.Type); + + if (e.ImplementationTypes.Count > 0) + { + Output.Write(" Implements "); + bool first = true; + foreach (CodeTypeReference type in e.ImplementationTypes) + { + if (first) + { + first = false; + } + else + { + Output.Write(" , "); + } + OutputType(type); + Output.Write("."); + OutputIdentifier(propName); + } + } + else if (e.PrivateImplementationType != null) + { + Output.Write(" Implements "); + OutputType(e.PrivateImplementationType); + Output.Write("."); + OutputIdentifier(propName); + } + + Output.WriteLine(""); + + if (!c.IsInterface && (e.Attributes & MemberAttributes.ScopeMask) != MemberAttributes.Abstract) + { + Indent++; + + if (e.HasGet) + { + + Output.WriteLine("Get"); + if (!IsCurrentInterface) + { + Indent++; + + GenerateVBStatements(e.GetStatements); + e.Name = propName; + + Indent--; + Output.WriteLine("End Get"); + } + } + if (e.HasSet) + { + Output.WriteLine("Set"); + if (!IsCurrentInterface) + { + Indent++; + GenerateVBStatements(e.SetStatements); + Indent--; + Output.WriteLine("End Set"); + } + } + Indent--; + Output.WriteLine("End Property"); + } + + e.Name = propName; + } + + /// + /// + /// Generates code for the specified CodeDom based property reference + /// expression representation. + /// + /// + protected override void GeneratePropertyReferenceExpression(CodePropertyReferenceExpression e) + { + + if (e.TargetObject != null) + { + GenerateExpression(e.TargetObject); + Output.Write("."); + Output.Write(e.PropertyName); + } + else + { + OutputIdentifier(e.PropertyName); + } + } + + /// + /// + /// Generates code for the specified CodeDom based constructor + /// representation. + /// + /// + protected override void GenerateConstructor(CodeConstructor e, CodeTypeDeclaration c) + { + if (!(IsCurrentClass || IsCurrentStruct)) return; + + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + OutputMemberAccessModifier(e.Attributes); + Output.Write("Sub New("); + OutputParameters(e.Parameters); + Output.WriteLine(")"); + Indent++; + + CodeExpressionCollection baseArgs = e.BaseConstructorArgs; + CodeExpressionCollection thisArgs = e.ChainedConstructorArgs; + + if (thisArgs.Count > 0) + { + Output.Write("Me.New("); + OutputExpressionList(thisArgs); + Output.Write(")"); + Output.WriteLine(""); + } + else if (baseArgs.Count > 0) + { + Output.Write("MyBase.New("); + OutputExpressionList(baseArgs); + Output.Write(")"); + Output.WriteLine(""); + } + else if (IsCurrentClass) + { + // struct doesn't have MyBase + Output.WriteLine("MyBase.New"); + } + + GenerateVBStatements(e.Statements); + Indent--; + Output.WriteLine("End Sub"); + } + /// + /// + /// Generates code for the specified CodeDom based class constructor + /// representation. + /// + /// + protected override void GenerateTypeConstructor(CodeTypeConstructor e) + { + if (!(IsCurrentClass || IsCurrentStruct)) return; + + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + Output.WriteLine("Shared Sub New()"); + Indent++; + GenerateVBStatements(e.Statements); + Indent--; + Output.WriteLine("End Sub"); + } + + protected override void GenerateTypeOfExpression(CodeTypeOfExpression e) + { + Output.Write("GetType("); + Output.Write(GetTypeOutput(e.Type)); + Output.Write(")"); + } + + /// + /// + /// Generates code for the CodeDom based class start representation. + /// + /// + protected override void GenerateTypeStart(CodeTypeDeclaration e) + { + if (IsCurrentDelegate) + { + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + + switch (e.TypeAttributes & TypeAttributes.VisibilityMask) + { + case TypeAttributes.Public: + Output.Write("Public "); + break; + case TypeAttributes.NotPublic: + default: + break; + } + + CodeTypeDelegate del = (CodeTypeDelegate)e; + if (del.ReturnType.BaseType.Length > 0 && string.Compare(del.ReturnType.BaseType, "System.Void", StringComparison.OrdinalIgnoreCase) != 0) + Output.Write("Delegate Function "); + else + Output.Write("Delegate Sub "); + OutputIdentifier(e.Name); + Output.Write("("); + OutputParameters(del.Parameters); + Output.Write(")"); + if (del.ReturnType.BaseType.Length > 0 && string.Compare(del.ReturnType.BaseType, "System.Void", StringComparison.OrdinalIgnoreCase) != 0) + { + Output.Write(" As "); + OutputType(del.ReturnType); + OutputArrayPostfix(del.ReturnType); + } + Output.WriteLine(""); + } + else if (e.IsEnum) + { + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + OutputTypeAttributes(e); + + OutputIdentifier(e.Name); + + if (e.BaseTypes.Count > 0) + { + Output.Write(" As "); + OutputType(e.BaseTypes[0]); + } + + Output.WriteLine(""); + Indent++; + } + else + { + if (e.CustomAttributes.Count > 0) + { + OutputAttributes(e.CustomAttributes, false); + } + OutputTypeAttributes(e); + + OutputIdentifier(e.Name); + OutputTypeParameters(e.TypeParameters); + + bool writtenInherits = false; + bool writtenImplements = false; + // For a structure we can't have an inherits clause + if (e.IsStruct) + { + writtenInherits = true; + } + // For an interface we can't have an implements clause + if (e.IsInterface) + { + writtenImplements = true; + } + Indent++; + foreach (CodeTypeReference typeRef in e.BaseTypes) + { + // if we're generating an interface, we always want to use Inherits because interfaces can't Implement anything. + if (!writtenInherits && (e.IsInterface || !typeRef.IsInterface)) + { + Output.WriteLine(""); + Output.Write("Inherits "); + writtenInherits = true; + } + else if (!writtenImplements) + { + Output.WriteLine(""); + Output.Write("Implements "); + writtenImplements = true; + } + else + { + Output.Write(", "); + } + OutputType(typeRef); + } + + Output.WriteLine(""); + } + } + + private void OutputTypeParameters(CodeTypeParameterCollection typeParameters) + { + if (typeParameters.Count == 0) + { + return; + } + + Output.Write("(Of "); + bool first = true; + for (int i = 0; i < typeParameters.Count; i++) + { + if (first) + { + first = false; + } + else + { + Output.Write(", "); + } + Output.Write(typeParameters[i].Name); + OutputTypeParameterConstraints(typeParameters[i]); + } + + Output.Write(')'); + } + + // In VB, constraints are put right after the type paramater name. + // In C#, there is a seperate "where" statement + private void OutputTypeParameterConstraints(CodeTypeParameter typeParameter) + { + CodeTypeReferenceCollection constraints = typeParameter.Constraints; + int constraintCount = constraints.Count; + if (typeParameter.HasConstructorConstraint) + { + constraintCount++; + } + + if (constraintCount == 0) + { + return; + } + + // generating something like: "ValType As {IComparable, Customer, New}" + Output.Write(" As "); + if (constraintCount > 1) + { + Output.Write(" {"); + } + + bool first = true; + foreach (CodeTypeReference typeRef in constraints) + { + if (first) + { + first = false; + } + else + { + Output.Write(", "); + } + Output.Write(GetTypeOutput(typeRef)); + } + + if (typeParameter.HasConstructorConstraint) + { + if (!first) + { + Output.Write(", "); + } + + Output.Write("New"); + } + + if (constraintCount > 1) + { + Output.Write('}'); + } + + } + + /// + /// + /// Generates code for the specified CodeDom based class end + /// representation. + /// + /// + protected override void GenerateTypeEnd(CodeTypeDeclaration e) + { + if (!IsCurrentDelegate) + { + Indent--; + string ending; + if (e.IsEnum) + { + ending = "End Enum"; + } + else if (e.IsInterface) + { + ending = "End Interface"; + } + else if (e.IsStruct) + { + ending = "End Structure"; + } + else + { + if (IsCurrentModule) + { + ending = "End Module"; + } + else + { + ending = "End Class"; + } + } + Output.WriteLine(ending); + } + } + + /// + /// + /// Generates code for the CodeDom based namespace representation. + /// + /// + protected override void GenerateNamespace(CodeNamespace e) + { + + if (GetUserData(e, "GenerateImports", true)) + { + GenerateNamespaceImports(e); + } + Output.WriteLine(); + GenerateCommentStatements(e.Comments); + GenerateNamespaceStart(e); + GenerateTypes(e); + GenerateNamespaceEnd(e); + } + + protected bool AllowLateBound(CodeCompileUnit e) + { + object o = e.UserData["AllowLateBound"]; + if (o != null && o is bool) + { + return (bool)o; + } + // We have Option Strict Off by default because it can fail on simple things like dividing + // two integers. + return true; + } + + protected bool RequireVariableDeclaration(CodeCompileUnit e) + { + object o = e.UserData["RequireVariableDeclaration"]; + if (o != null && o is bool) + { + return (bool)o; + } + return true; + } + + private bool GetUserData(CodeObject e, string property, bool defaultValue) + { + object o = e.UserData[property]; + if (o != null && o is bool) + { + return (bool)o; + } + return defaultValue; + } + + protected override void GenerateCompileUnitStart(CodeCompileUnit e) + { + base.GenerateCompileUnitStart(e); + Output.WriteLine("'------------------------------------------------------------------------------"); + Output.WriteLine("' "); + Output.Write("' "); + Output.WriteLine(SRCodeDom.AutoGen_Comment_Line2); + Output.WriteLine("'"); + Output.Write("' "); + Output.WriteLine(SRCodeDom.AutoGen_Comment_Line4); + Output.Write("' "); + Output.WriteLine(SRCodeDom.AutoGen_Comment_Line5); + Output.WriteLine("' "); + Output.WriteLine("'------------------------------------------------------------------------------"); + Output.WriteLine(""); + + if (e.StartDirectives.Count > 0) + { + GenerateDirectives(e.StartDirectives); + } + + Output.WriteLine(); + } + + protected override void GenerateCompileUnit(CodeCompileUnit e) + { + + GenerateCompileUnitStart(e); + + SortedList importList; + // Visual Basic needs all the imports together at the top of the compile unit. + // If generating multiple namespaces, gather all the imports together + importList = new SortedList(StringComparer.OrdinalIgnoreCase); + foreach (CodeNamespace nspace in e.Namespaces) + { + // mark the namespace to stop it generating its own import list + nspace.UserData["GenerateImports"] = false; + + // Collect the unique list of imports + foreach (CodeNamespaceImport import in nspace.Imports) + { + if (!importList.Contains(import.Namespace)) + { + importList.Add(import.Namespace, import.Namespace); + } + } + } + // now output the imports + foreach (string import in importList.Keys) + { + Output.Write("Imports "); + OutputIdentifier(import); + Output.WriteLine(""); + } + + if (e.AssemblyCustomAttributes.Count > 0) + { + OutputAttributes(e.AssemblyCustomAttributes, false, "Assembly: ", true); + } + + GenerateNamespaces(e); + GenerateCompileUnitEnd(e); + } + + protected override void GenerateDirectives(CodeDirectiveCollection directives) + { + for (int i = 0; i < directives.Count; i++) + { + CodeDirective directive = directives[i]; + if (directive is CodeChecksumPragma) + { + GenerateChecksumPragma((CodeChecksumPragma)directive); + } + else if (directive is CodeRegionDirective) + { + GenerateCodeRegionDirective((CodeRegionDirective)directive); + } + } + } + + private void GenerateChecksumPragma(CodeChecksumPragma checksumPragma) + { + // the syntax is: #ExternalChecksum("FileName","GuidChecksum","ChecksumValue") + Output.Write("#ExternalChecksum(\""); + Output.Write(checksumPragma.FileName); + Output.Write("\",\""); + Output.Write(checksumPragma.ChecksumAlgorithmId.ToString("B", CultureInfo.InvariantCulture)); + Output.Write("\",\""); + if (checksumPragma.ChecksumData != null) + { + foreach (Byte b in checksumPragma.ChecksumData) + { + Output.Write(b.ToString("X2", CultureInfo.InvariantCulture)); + } + } + Output.WriteLine("\")"); + } + + private void GenerateCodeRegionDirective(CodeRegionDirective regionDirective) + { + // VB does not support regions within statement blocks + if (IsGeneratingStatements()) + { + return; + } + if (regionDirective.RegionMode == CodeRegionMode.Start) + { + Output.Write("#Region \""); + Output.Write(regionDirective.RegionText); + Output.WriteLine("\""); + } + else if (regionDirective.RegionMode == CodeRegionMode.End) + { + Output.WriteLine("#End Region"); + } + } + + /// + /// + /// Generates code for the specified CodeDom based namespace representation. + /// + /// + protected override void GenerateNamespaceStart(CodeNamespace e) + { + if (e.Name != null && e.Name.Length > 0) + { + Output.Write("Namespace "); + string[] names = e.Name.Split('.'); + Debug.Assert(names.Length > 0); + OutputIdentifier(names[0]); + for (int i = 1; i < names.Length; i++) + { + Output.Write("."); + OutputIdentifier(names[i]); + } + Output.WriteLine(); + Indent++; + } + } + + /// + /// + /// Generates code for the specified CodeDom based namespace representation. + /// + /// + protected override void GenerateNamespaceEnd(CodeNamespace e) + { + if (e.Name != null && e.Name.Length > 0) + { + Indent--; + Output.WriteLine("End Namespace"); + } + } + + /// + /// + /// Generates code for the specified CodeDom based namespace import + /// representation. + /// + /// + protected override void GenerateNamespaceImport(CodeNamespaceImport e) + { + Output.Write("Imports "); + OutputIdentifier(e.Namespace); + Output.WriteLine(""); + } + + /// + /// + /// Generates code for the specified CodeDom based attribute block start + /// representation. + /// + /// + protected override void GenerateAttributeDeclarationsStart(CodeAttributeDeclarationCollection attributes) + { + Output.Write("<"); + } + /// + /// + /// Generates code for the specified CodeDom based attribute block end + /// representation. + /// + /// + protected override void GenerateAttributeDeclarationsEnd(CodeAttributeDeclarationCollection attributes) + { + Output.Write(">"); + } + + public static bool IsKeyword(string value) + { + return FixedStringLookup.Contains(s_keywords, value, true); + } + + protected override bool Supports(GeneratorSupport support) + { + return ((support & LanguageSupport) == support); + } + + /// + /// + /// Gets whether the specified identifier is valid. + /// + /// + protected override bool IsValidIdentifier(string value) + { + + // identifiers must be 1 char or longer + // + if (value == null || value.Length == 0) + { + return false; + } + + if (value.Length > 1023) + return false; + + // identifiers cannot be a keyword unless surrounded by []'s + // + if (value[0] != '[' || value[value.Length - 1] != ']') + { + if (IsKeyword(value)) + { + return false; + } + } + else + { + value = value.Substring(1, value.Length - 2); + } + + // just _ as an identifier is not valid. + if (value.Length == 1 && value[0] == '_') + return false; + + return CodeGenerator.IsValidLanguageIndependentIdentifier(value); + } + + protected override string CreateValidIdentifier(string name) + { + if (IsKeyword(name)) + { + return "_" + name; + } + return name; + } + + protected override string CreateEscapedIdentifier(string name) + { + if (IsKeyword(name)) + { + return "[" + name + "]"; + } + return name; + } + + private string GetBaseTypeOutput(CodeTypeReference typeRef) + { + string baseType = typeRef.BaseType; + + if (baseType.Length == 0) + { + return "Void"; + } + else if (string.Compare(baseType, "System.Byte", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Byte"; + } + else if (string.Compare(baseType, "System.SByte", StringComparison.OrdinalIgnoreCase) == 0) + { + return "SByte"; + } + else if (string.Compare(baseType, "System.Int16", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Short"; + } + else if (string.Compare(baseType, "System.Int32", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Integer"; + } + else if (string.Compare(baseType, "System.Int64", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Long"; + } + else if (string.Compare(baseType, "System.UInt16", StringComparison.OrdinalIgnoreCase) == 0) + { + return "UShort"; + } + else if (string.Compare(baseType, "System.UInt32", StringComparison.OrdinalIgnoreCase) == 0) + { + return "UInteger"; + } + else if (string.Compare(baseType, "System.UInt64", StringComparison.OrdinalIgnoreCase) == 0) + { + return "ULong"; + } + else if (string.Compare(baseType, "System.String", StringComparison.OrdinalIgnoreCase) == 0) + { + return "String"; + } + else if (string.Compare(baseType, "System.DateTime", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Date"; + } + else if (string.Compare(baseType, "System.Decimal", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Decimal"; + } + else if (string.Compare(baseType, "System.Single", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Single"; + } + else if (string.Compare(baseType, "System.Double", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Double"; + } + else if (string.Compare(baseType, "System.Boolean", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Boolean"; + } + else if (string.Compare(baseType, "System.Char", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Char"; + } + else if (string.Compare(baseType, "System.Object", StringComparison.OrdinalIgnoreCase) == 0) + { + return "Object"; + } + else + { + StringBuilder sb = new StringBuilder(baseType.Length + 10); + if ((typeRef.Options & CodeTypeReferenceOptions.GlobalReference) != 0) + { + sb.Append("Global."); + } + + int lastIndex = 0; + int currentTypeArgStart = 0; + for (int i = 0; i < baseType.Length; i++) + { + switch (baseType[i]) + { + case '+': + case '.': + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); + sb.Append('.'); + i++; + lastIndex = i; + break; + + case '`': + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex, i - lastIndex))); + i++; // skip the ' + int numTypeArgs = 0; + while (i < baseType.Length && baseType[i] >= '0' && baseType[i] <= '9') + { + numTypeArgs = numTypeArgs * 10 + (baseType[i] - '0'); + i++; + } + + GetTypeArgumentsOutput(typeRef.TypeArguments, currentTypeArgStart, numTypeArgs, sb); + currentTypeArgStart += numTypeArgs; + + // Arity can be in the middle of a nested type name, so we might have a . or + after it. + // Skip it if so. + if (i < baseType.Length && (baseType[i] == '+' || baseType[i] == '.')) + { + sb.Append('.'); + i++; + } + + lastIndex = i; + break; + } + } + + if (lastIndex < baseType.Length) + sb.Append(CreateEscapedIdentifier(baseType.Substring(lastIndex))); + + return sb.ToString(); + } + } + + private string GetTypeOutputWithoutArrayPostFix(CodeTypeReference typeRef) + { + StringBuilder sb = new StringBuilder(); + + while (typeRef.ArrayElementType != null) + { + typeRef = typeRef.ArrayElementType; + } + + sb.Append(GetBaseTypeOutput(typeRef)); + return sb.ToString(); + } + + private String GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArguments) + { + StringBuilder sb = new StringBuilder(128); + GetTypeArgumentsOutput(typeArguments, 0, typeArguments.Count, sb); + return sb.ToString(); + } + + private void GetTypeArgumentsOutput(CodeTypeReferenceCollection typeArguments, int start, int length, StringBuilder sb) + { + sb.Append("(Of "); + bool first = true; + for (int i = start; i < start + length; i++) + { + if (first) + { + first = false; + } + else + { + sb.Append(", "); + } + + // it's possible that we call GetTypeArgumentsOutput with an empty typeArguments collection. This is the case + // for open types, so we want to just output the brackets and commas. + if (i < typeArguments.Count) + sb.Append(GetTypeOutput(typeArguments[i])); + } + sb.Append(')'); + } + + protected override string GetTypeOutput(CodeTypeReference typeRef) + { + string s = String.Empty; + s += GetTypeOutputWithoutArrayPostFix(typeRef); + + if (typeRef.ArrayRank > 0) + { + s += GetArrayPostfix(typeRef); + } + return s; + } + + protected override void ContinueOnNewLine(string st) + { + Output.Write(st); + Output.WriteLine(" _"); + } + + private bool IsGeneratingStatements() + { + Debug.Assert(_statementDepth >= 0, "statementDepth >= 0"); + return (_statementDepth > 0); + } + + private void GenerateVBStatements(CodeStatementCollection stms) + { + _statementDepth++; + try + { + GenerateStatements(stms); + } + finally + { + _statementDepth--; + } + } + + protected override CompilerResults FromFileBatch(CompilerParameters options, string[] fileNames) + { + if (options == null) + { + throw new ArgumentNullException("options"); + } + if (fileNames == null) + throw new ArgumentNullException("fileNames"); + + string outputFile = null; + int retValue = 0; + + CompilerResults results = new CompilerResults(options.TempFiles); + bool createdEmptyAssembly = false; + + string extension = (options.GenerateExecutable) ? "exe" : "dll"; + string extensionWithDot = '.' + extension; + + if (options.OutputAssembly == null || options.OutputAssembly.Length == 0) + { + options.OutputAssembly = results.TempFiles.AddExtension(extension, !options.GenerateInMemory); + + // Create an empty assembly. This is so that the file will have permissions that + // we can later access with our current credential.If we don't do this, the compiler + // could end up creating an assembly that we cannot open (bug ASURT 83492) + new FileStream(options.OutputAssembly, FileMode.Create, FileAccess.ReadWrite).Close(); + createdEmptyAssembly = true; + } + + String outputAssemblyFile = options.OutputAssembly; + + if (!Path.GetExtension(outputAssemblyFile).Equals(extensionWithDot, StringComparison.OrdinalIgnoreCase)) + { + // The vb compiler automatically appends the 'dll' or 'exe' extension if it's not present. + // We similarly determine the file name, so we can find it later. + outputAssemblyFile += extensionWithDot; + } + +#if FEATURE_PAL + string pdbname = "ildb"; +#else + string pdbname = "pdb"; +#endif + + // hack so that we don't delete pdbs when debug=false but they have specified pdbonly. + if (options.CompilerOptions != null && options.CompilerOptions.IndexOf("/debug:pdbonly", StringComparison.OrdinalIgnoreCase) != -1) + results.TempFiles.AddExtension(pdbname, true); + else + results.TempFiles.AddExtension(pdbname); + + string args = CmdArgsFromParameters(options) + " " + JoinStringArray(fileNames, " "); + + // Use a response file if the compiler supports it + string responseFileArgs = GetResponseFileCmdArgs(options, args); + string trueArgs = null; + if (responseFileArgs != null) + { + trueArgs = args; + args = responseFileArgs; + } + + Compile(options, + RedistVersionInfo.GetCompilerPath(_provOptions, CompilerName), + CompilerName, + args, + ref outputFile, + ref retValue, + trueArgs); + + results.NativeCompilerReturnValue = retValue; + + // only look for errors/warnings if the compile failed or the caller set the warning level + if (retValue != 0 || options.WarningLevel > 0) + { + // The VB Compiler generates multi-line error messages. Currently, the best way to obtain the + // full message without going too far, is to use the distinction between \n and \r\n. + // For multi-line error messages, the former is always output between lines of an error message, + // and the latter is output at the end. So this rearranges the output of File.ReadAllLines + // so that an error message is contained on a line. + // + // As of now, this is the best way to match a full error message. This is because the compiler + // may output other trailing data which isn't an error msg or warning, but doesn't belong to + // the error message. So trailing data could get tacked on since the message doesn't always end + // with punctuation or some other marker. I confirmed this with the VBC group. + byte[] fileBytes = ReadAllBytes(outputFile, FileShare.ReadWrite); + + // The output of the compiler is in UTF8 + string fileStr = Encoding.UTF8.GetString(fileBytes); + + // Split lines only around \r\n (see above) + string[] lines = Regex.Split(fileStr, @"\r\n"); + + foreach (string line in lines) + { + results.Output.Add(line); + + ProcessCompilerOutputLine(results, line); + } + + // Delete the empty assembly if we created one + if (retValue != 0 && createdEmptyAssembly) + File.Delete(outputAssemblyFile); + } + + if (results.Errors.HasErrors || !options.GenerateInMemory) + { + results.PathToAssembly = options.OutputAssembly; + return results; + } + + results.CompiledAssembly = Assembly.Load(new AssemblyName(options.OutputAssembly)); + return results; + } + + private static byte[] ReadAllBytes(String file, FileShare share) + { + byte[] bytes; + using (FileStream stream = File.Open(file, FileMode.Open, FileAccess.Read, share)) + { + int index = 0; + long fileLength = stream.Length; + if (fileLength > Int32.MaxValue) + throw new ArgumentOutOfRangeException("file"); + + int count = (int)fileLength; + bytes = new byte[count]; + while (count > 0) + { + int n = stream.Read(bytes, index, count); + if (n == 0) + throw new EndOfStreamException(); + index += n; + count -= n; + } + } + return bytes; + } + } // VBCodeGenerator + + #endregion class VBCodeGenerator + + + #region class VBMemberAttributeConverter + + internal class VBMemberAttributeConverter : VBModifierAttributeConverter + { + private static volatile string[] s_names; + private static volatile object[] s_values; + private static volatile VBMemberAttributeConverter s_defaultConverter; + + private VBMemberAttributeConverter() + { + // no need to create an instance; use Default + } + + public static VBMemberAttributeConverter Default + { + get + { + if (s_defaultConverter == null) + { + s_defaultConverter = new VBMemberAttributeConverter(); + } + return s_defaultConverter; + } + } + + /// + /// Retrieves an array of names for attributes. + /// + protected override string[] Names + { + get + { + if (s_names == null) + { + s_names = new string[] { + "Public", + "Protected", + "Protected Friend", + "Friend", + "Private" + }; + } + + return s_names; + } + } + + /// + /// Retrieves an array of values for attributes. + /// + protected override object[] Values + { + get + { + if (s_values == null) + { + s_values = new object[] { + (object)MemberAttributes.Public, + (object)MemberAttributes.Family, + (object)MemberAttributes.FamilyOrAssembly, + (object)MemberAttributes.Assembly, + (object)MemberAttributes.Private + }; + } + + return s_values; + } + } + + protected override object DefaultValue + { + get + { + return MemberAttributes.Private; + } + } + } // VBMemberAttributeConverter + + #endregion class VBMemberAttributeConverter + + + #region class VBTypeAttributeConverter + + internal class VBTypeAttributeConverter : VBModifierAttributeConverter + { + private static volatile VBTypeAttributeConverter s_defaultConverter; + private static volatile string[] s_names; + private static volatile object[] s_values; + + private VBTypeAttributeConverter() + { + // no need to create an instance; use Default + } + + public static VBTypeAttributeConverter Default + { + get + { + if (s_defaultConverter == null) + { + s_defaultConverter = new VBTypeAttributeConverter(); + } + return s_defaultConverter; + } + } + + /// + /// Retrieves an array of names for attributes. + /// + protected override string[] Names + { + get + { + if (s_names == null) + { + s_names = new string[] { + "Public", + "Friend" + }; + } + + return s_names; + } + } + + /// + /// Retrieves an array of values for attributes. + /// + protected override object[] Values + { + get + { + if (s_values == null) + { + s_values = new object[] { + (object)TypeAttributes.Public, + (object)TypeAttributes.NotPublic + }; + } + + return s_values; + } + } + + protected override object DefaultValue + { + get + { + return TypeAttributes.Public; + } + } + } // VBTypeAttributeConverter + + #endregion class VBTypeAttributeConverter + + + #region class VBModifierAttributeConverter + + /// + /// This type converter provides common values for MemberAttributes + /// + internal abstract class VBModifierAttributeConverter : TypeConverter + { + + protected abstract object[] Values { get; } + protected abstract string[] Names { get; } + protected abstract object DefaultValue { get; } + + /// + /// We override this because we can convert from string types. + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + { + return true; + } + + return base.CanConvertFrom(context, sourceType); + } + + /// + /// Converts the given object to the converter's native type. + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value is string) + { + string name = (string)value; + string[] names = Names; + for (int i = 0; i < names.Length; i++) + { + if (names[i].Equals(name, StringComparison.OrdinalIgnoreCase)) + { + return Values[i]; + } + } + } + + return DefaultValue; + } + + /// + /// Converts the given object to another type. The most common types to convert + /// are to and from a string object. The default implementation will make a call + /// to ToString on the object if the object is valid and if the destination + /// type is string. If this cannot convert to the desitnation type, this will + /// throw a NotSupportedException. + /// + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == null) + { + throw new ArgumentNullException("destinationType"); + } + + if (destinationType == typeof(string)) + { + object[] modifiers = Values; + for (int i = 0; i < modifiers.Length; i++) + { + if (modifiers[i].Equals(value)) + { + return Names[i]; + } + } + + return string.Format(SRCodeDom.toStringUnknown); + } + + return base.ConvertTo(context, culture, value, destinationType); + } + + /// + /// Determines if the list of standard values returned from + /// GetStandardValues is an exclusive list. If the list + /// is exclusive, then no other values are valid, such as + /// in an enum data type. If the list is not exclusive, + /// then there are other valid values besides the list of + /// standard values GetStandardValues provides. + /// + public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) + { + return true; + } + + /// + /// Determines if this object supports a standard set of values + /// that can be picked from a list. + /// + public override bool GetStandardValuesSupported(ITypeDescriptorContext context) + { + return true; + } + + /// + /// Retrieves a collection containing a set of standard values + /// for the data type this validator is designed for. This + /// will return null if the data type does not support a + /// standard set of values. + /// + public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) + { + return new StandardValuesCollection(Values); + } + } // VBModifierAttributeConverter + + #endregion class VBModifierAttributeConverter +} // namespace diff --git a/src/dotnet-svcutil/lib/src/HelpGenerator.cs b/src/dotnet-svcutil/lib/src/HelpGenerator.cs index 623bfb766618..1bcb40349f8b 100644 --- a/src/dotnet-svcutil/lib/src/HelpGenerator.cs +++ b/src/dotnet-svcutil/lib/src/HelpGenerator.cs @@ -70,7 +70,8 @@ private static void WriteCodeGenerationHelp() ArgumentInfo.CreateParameterHelpInfo(CommandProcessorOptions.Switches.RuntimeIdentifier.Name, SR.ParametersRuntimeIdentifier, string.Format(SR.HelpRuntimeIdentifierFormat, CommandProcessorOptions.Switches.RuntimeIdentifier.Abbreviation)), ArgumentInfo.CreateParameterHelpInfo(CommandProcessorOptions.Switches.TargetFramework.Name, SR.ParametersTargetFramework, string.Format(SR.HelpTargetFrameworkFormat, CommandProcessorOptions.Switches.TargetFramework.Abbreviation)), ArgumentInfo.CreateFlagHelpInfo( CommandProcessorOptions.Switches.AcceptCertificate.Name, string.Format(SR.HelpAcceptCertificateFormat, CommandProcessorOptions.Switches.AcceptCertificate.Abbreviation)), - ArgumentInfo.CreateFlagHelpInfo( CommandProcessorOptions.Switches.ServiceContract.Name, string.Format(SR.HelpServiceContractFormat, CommandProcessorOptions.Switches.ServiceContract.Abbreviation)) + ArgumentInfo.CreateFlagHelpInfo( CommandProcessorOptions.Switches.ServiceContract.Name, string.Format(SR.HelpServiceContractFormat, CommandProcessorOptions.Switches.ServiceContract.Abbreviation)), + ArgumentInfo.CreateFlagHelpInfo( CommandProcessorOptions.Switches.Language.Name, string.Format(SR.HelpLanguage, CommandProcessorOptions.Switches.Language.Abbreviation)) } }; diff --git a/src/dotnet-svcutil/lib/src/SR.resx b/src/dotnet-svcutil/lib/src/SR.resx index b2de15ffded3..9732015dc097 100644 --- a/src/dotnet-svcutil/lib/src/SR.resx +++ b/src/dotnet-svcutil/lib/src/SR.resx @@ -625,4 +625,10 @@ Your credentials will be sent to the server in clear text. NetNamedPipe is not supported on current .net target framework. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs index b1c5781515d3..d49c8089a75b 100644 --- a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs +++ b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs @@ -27,6 +27,7 @@ internal partial class UpdateOptions : ApplicationOptions public const string TargetFrameworkKey = "targetFramework"; public const string TypeReuseModeKey = "typeReuseMode"; public const string WrappedKey = "wrapped"; + public const string LanguageKey = "language"; #endregion #region properties @@ -45,6 +46,7 @@ internal partial class UpdateOptions : ApplicationOptions public FrameworkInfo TargetFramework { get { return GetValue(TargetFrameworkKey); } set { SetValue(TargetFrameworkKey, value); } } public TypeReuseMode? TypeReuseMode { get { return GetValue(TypeReuseModeKey); } set { SetValue(TypeReuseModeKey, value); } } public bool? Wrapped { get { return GetValue(WrappedKey); } set { SetValue(WrappedKey, value); } } + public string Language { get { return GetValue(LanguageKey); } set { SetValue(LanguageKey, value); } } #endregion public UpdateOptions() @@ -64,7 +66,8 @@ public UpdateOptions() new SingleValueOption(SyncKey) { SerializationName = "sync" }, new SingleValueOption(TargetFrameworkKey), new SingleValueOption(TypeReuseModeKey), - new SingleValueOption(WrappedKey)); + new SingleValueOption(WrappedKey), + new SingleValueOption(LanguageKey)); } public static UpdateOptions FromFile(string filePath, bool throwOnError = true) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.cs.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.cs.xlf index da5b285d97aa..035f514a96f0 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.cs.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.cs.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being K tomu může dojít v případě, že jazyk nepodporuje všechny generované elementy kódu. Zvažte možnost použít jiný jazyk. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. Pro hodnotu {0} předanou možnosti --{1} se nepovedlo vytvořit poskytovatele kódu. Ověřte, že je poskytovatel kódu správně nainstalovaný a nakonfigurovaný. @@ -547,6 +552,11 @@ Identifikátor dokumentu: {0} Vygeneruje třídy, které jsou označeny jako vnitřní. Výchozí: generovat veřejné třídy (Krátký tvar: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) Programovací jazyk, v němž bude vygenerován kód. Poskytněte prosím buď název jazyka zaregistrovaný v souboru machine.config, nebo plně kvalifikovaný název třídy, která dědí ze třídy System.CodeDom.Compiler.CodeDomProvider. Příklady názvů jazyků, které lze použít, jsou CS a VB. Výchozí: C# (Krátký tvar: /{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.de.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.de.xlf index ad6faa964fc2..176936729463 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.de.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.de.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being Dies kann daran liegen, dass nicht alle zu generierenden Codeelemente von der Sprache unterstützt werden. Verwenden Sie ggf. eine andere Sprache. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. Für den an die Option --{1} übergebenen Wert "{0}" konnte kein Codeanbieter erstellt werden. Überprüfen Sie, ob der Codeanbieter ordnungsgemäß installiert und konfiguriert ist. @@ -547,6 +552,11 @@ Dokumentbezeichner: "{0}". Klassen generieren, die als intern markiert sind. Standard: öffentliche Klassen generieren. (Kurzform: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) Die Programmiersprache, mit der Code generiert wird. Geben Sie entweder einen in der Datei "machine.config" registrierten Sprachennamen an, oder geben Sie den vollqualifizierten Namen einer Klasse an, die von System.CodeDom.Compiler.CodeDomProvider erbt. Beispiele für zu verwendende Sprachennamen sind "CS" und "VB". Standard: C#. (Kurzform: /{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.es.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.es.xlf index 22b7875ad1a6..0efdd4f84fd8 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.es.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.es.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being Esto se puede deber a que el lenguaje no admite todos los elementos de código que se generan. Considere la posibilidad de utilizar otro lenguaje. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. No se pudo crear ningún proveedor de código para el valor "{0}" pasado a la opción --{1}. Compruebe que el proveedor de código está instalado y configurado correctamente. @@ -547,6 +552,11 @@ Identificador del documento: "{0}". Generar clases que se marquen como internas. Valor predeterminado: generar clases públicas. (Forma corta: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) El lenguaje de programación que se va a utilizar para generar código. Proporcione un nombre de lenguaje registrado en el archivo machine.config o el nombre completo de una clase que se herede de System.CodeDom.Compiler.CodeDomProvider. Algunos ejemplos de nombres de lenguaje que se utilizan son CS y VB. Valor predeterminado: C#. (Forma corta: /{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.fr.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.fr.xlf index 79eda9299e5b..dddd8002c1f3 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.fr.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.fr.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being Le langage ne prend peut-être pas en charge tous les éléments de code générés. Utilisez un autre langage. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. Impossible de créer un fournisseur de code pour la valeur '{0}' passée à l'option --{1}. Vérifiez que le fournisseur de code est installé et configuré correctement. @@ -547,6 +552,11 @@ Identificateur de document : '{0}'. Générer des classes marquées comme internes. Valeur par défaut : générer des classes publiques. (Forme abrégée : /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) Langage de programmation utilisé pour la génération du code. Indiquez un nom de langage inscrit dans le fichier machine.config ou le nom complet d'une classe qui hérite de System.CodeDom.Compiler.CodeDomProvider. Les noms de langage à utiliser sont par exemple CS et VB. Valeur par défaut : C#. (Forme abrégée : /{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.it.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.it.xlf index 8de4d8b3d392..3485c0feff70 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.it.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.it.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being Il problema potrebbe dipendere dal fatto che il linguaggio non supporta tutti gli elementi del codice da generare. Provare a usare un altro linguaggio. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. Non è stato possibile creare un provider di codice per il valore '{0}' passato all'opzione --{1}. Verificare che il provider di codice sia installato e configurato correttamente. @@ -547,6 +552,11 @@ Identificatore di documento: '{0}'. Genera le classi contrassegnate come interne. Impostazione predefinita: genera classi pubbliche. Forma breve: -{0} + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) Linguaggio di programmazione da usare per la generazione del codice. Specificare un nome di linguaggio registrato nel file machine.config o il nome completo di una classe che eredita da System.CodeDom.Compiler.CodeDomProvider. Esempi di nomi di linguaggio da usare sono CS e VB. Impostazione predefinita: C#. Forma breve: -{0} diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.ja.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.ja.xlf index fd0898b74571..6395b65e80bd 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.ja.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.ja.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being その言語が、生成されるコード要素をすべてはサポートしていないことが原因である可能性があります。別の言語を使用することを検討してください。 + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. --{1} オプションに渡された値 '{0}' に対して、コード プロバイダーを作成できませんでした。コード プロバイダーが正しくインストールおよび構成されていることをご確認ください。 @@ -547,6 +552,11 @@ Document Identifier: '{0}'. 内部クラスのマークが付けられたクラスを生成します。既定: パブリック クラスを生成します。(短い形式: -{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) コードの生成に使用するプログラミング言語です。machine.config ファイルに登録された言語名を指定するか、System.CodeDom.Compiler.CodeDomProvider から継承するクラスの完全修飾名を指定します。使用する言語名の例は CS および VB です。既定: C#。(短い形式: -{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.ko.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.ko.xlf index a7bc4698ae62..21f3cd42e51e 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.ko.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.ko.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being 이 언어에서 생성 중인 코드 요소 중 일부만 지원하기 때문일 수 있습니다. 다른 언어를 사용해 보세요. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. --{1} 옵션에 전달된 '{0}' 값에 대해 코드 공급자를 만들 수 없습니다. 코드 공급자가 제대로 설치되고 구성되었는지 확인하세요. @@ -547,6 +552,11 @@ Document Identifier: '{0}'. 내부로 표시된 클래스를 생성합니다. 기본값: 공용 클래스를 생성합니다(약식: -{0}). + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) 코드를 생성하는 데 사용할 프로그래밍 언어입니다. machine.config 파일에 등록된 언어 이름을 제공하거나 System.CodeDom.Compiler.CodeDomProvider에서 상속되는 클래스의 정규화된 이름을 제공하세요. 사용할 언어 이름의 예로는 CS, VB 등이 있습니다. 기본값: C#(약식: -{0}). diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.pl.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.pl.xlf index c541ee9a9ba0..92740ef9d254 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.pl.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.pl.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being Przyczyną może być język, który nie obsługuje wszystkich elementów kodu do wygenerowania. Rozważ użycie innego języka. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. Nie można utworzyć dostawcy kodu dla wartości „{0}” przekazanej do opcji --{1}. Upewnij się, że dostawca kodu został prawidłowo zainstalowany i skonfigurowany. @@ -547,6 +552,11 @@ Identyfikator dokumentu: „{0}”. Generuj klasy, które są oznaczone jako wewnętrzne. Domyślnie: generuj klasy publiczne. (Krótka wersja: -{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) Język programowania służący do wygenerowania kodu. Podaj nazwę języka zarejestrowaną w pliku machine.config lub w pełni kwalifikowaną nazwę klasy, która dziedziczy z elementu System.CodeDom.Compiler.CodeDomProvider. Przykłady nazw języków do wykorzystania to CS i VB. Domyślnie: C#. (Krótka wersja: -{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.pt-BR.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.pt-BR.xlf index 2ec561d990d3..0fc3faf82ab8 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.pt-BR.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.pt-BR.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being Isso pode ter ocorrido porque a linguagem não dá suporte para todos os elementos do código sendo gerado. Considere usar outra linguagem. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. Não foi possível criar um provedor de código para o valor: '{0}' passado à opção --{1}. Verifique se o provedor de código está instalado e configurado corretamente. @@ -547,6 +552,11 @@ Identificador do Documento: '{0}'. Gere classes marcadas como internas. Padrão: gerar classes públicas. (Forma Abreviada: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) A linguagem de programação a ser usada para gerar código. Forneça o nome da linguagem registrado no arquivo machine.config ou o nome totalmente qualificado de uma classe que herda de System.CodeDom.Compiler.CodeDomProvider. Entre os exemplos de nomes de linguagem a serem usados estão CS e VB. Padrão: C#. (Forma Abreviada: /{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.ru.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.ru.xlf index 4b47ad5f3bb6..3574eb00b78c 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.ru.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.ru.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being Возможная причина: язык не поддерживает все элементы создаваемого кода. Попробуйте применить другой язык. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. Не удалось создать поставщик кода для значения "{0}", переданного для параметра --{1}. Убедитесь, что поставщик кода установлен и настроен правильно. @@ -547,6 +552,11 @@ Document Identifier: '{0}'. Формирование классов, отмеченных как внутренние. По умолчанию: формирование открытых классов. (Краткая форма: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) Язык программирования для формирования кода. Предоставьте имя языка, зарегистрированного в файле machine.config, или полное имя класса, который наследует у System.CodeDom.Compiler.CodeDomProvider. Примеры имен языков, которые следует использовать: CS и VB. По умолчанию: C#. (Краткая форма: /{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.tr.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.tr.xlf index 2769c730ea67..1ca5df6d284a 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.tr.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.tr.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being Bunun nedeni, dilin oluşturulmakta olan tüm kod öğelerini desteklememesi olabilir. Başka bir dil kullanmayı deneyin. + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. --{1} seçeneğine geçirilen '{0}' değeri için bir kod sağlayıcısı oluşturulamadı. Kod sağlayıcısının düzgün bir biçimde yüklenip yapılandırıldığından emin olun. @@ -547,6 +552,11 @@ Belge Tanımlayıcısı: '{0}'. İç olarak işaretlenmiş sınıflar oluşturun. Varsayılan: Genel sınıflar oluşturma. (Kısa Biçim: -{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) Kod oluşturmak için kullanılan programlama dili. machine.config dosyasında kayıtlı bir dili ya da System.CodeDom.Compiler.CodeDomProvider'dan devralan bir sınıfın tam adını sağlayın. Kullanılabilecek dil adlarına örnek olarak CS ve VB verilebilir. Varsayılan: C#. (Kısa Biçim: -{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.zh-Hans.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.zh-Hans.xlf index f39751cf853a..7c8cd509bd69 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.zh-Hans.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.zh-Hans.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being 这可能是由于该语言不支持正在生成的所有代码元素。请考虑使用其他语言。 + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. 无法为传递给 --{1} 选项的值“{0}”创建代码提供程序。请验证是否正确安装并配置了代码提供程序。 @@ -547,6 +552,11 @@ Document Identifier: '{0}'. 生成标记为内部的类。默认设置: 生成公共类。(缩写: -{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) 用于生成代码的编程语言。提供在 machine.config 文件中注册的语言名称,或提供从 System.CodeDom.Compiler.CodeDomProvider 继承的类的完全限定名称。要使用的语言名称示例包括 CS 和 VB。默认语言名称: C#。(缩写: -{0}) diff --git a/src/dotnet-svcutil/lib/src/xlf/SR.zh-Hant.xlf b/src/dotnet-svcutil/lib/src/xlf/SR.zh-Hant.xlf index 97f9185047f5..911949f51054 100644 --- a/src/dotnet-svcutil/lib/src/xlf/SR.zh-Hant.xlf +++ b/src/dotnet-svcutil/lib/src/xlf/SR.zh-Hant.xlf @@ -209,6 +209,11 @@ This could be because the language does not support all the code elements being 這可能是因為該語言不支援要產生的所有程式碼元素。請考慮使用其他語言。 + + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + A code provider could not be created for the value: '{0}' passed to the /{1} argument. Verify that the code provider is properly installed and configured. + + A code provider could not be created for the value: '{0}' passed to the --{1} option. Verify that the code provider is properly installed and configured. 無法為傳遞到 --{1} 選項的值: '{0}' 建立程式碼提供者。請確認已正確安裝與設定程式碼提供者。 @@ -547,6 +552,11 @@ Document Identifier: '{0}'. 產生標示為內部的類別。預設: 產生公用類別。(簡短形式: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: /{0}) + + The programming language to use for generating code. Provide either a language name registered in the machine.config file or provide the fully-qualified name of a class that inherits from System.CodeDom.Compiler.CodeDomProvider. Examples of language names to use are CS and VB. Default: C#. (Short Form: -{0}) 用於產生程式碼的程式設計語言。請提供已在 machine.config 檔案中註冊的語言名稱,或提供從 System.CodeDom.Compiler.CodeDomProvider 繼承之類別的完整名稱。要使用的語言名稱範例是 CS 與 VB。預設: C#。(簡短形式: /{0}) diff --git a/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/CS.csproj b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/CS.csproj new file mode 100644 index 000000000000..346742f0a5fc --- /dev/null +++ b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/CS.csproj @@ -0,0 +1,16 @@ + + + + Exe + N.N + enable + enable + + + + + + + + + \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/ServiceReference/Reference.cs b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/ServiceReference/Reference.cs new file mode 100644 index 000000000000..cfe70ab35c87 --- /dev/null +++ b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/ServiceReference/Reference.cs @@ -0,0 +1,190 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ServiceReference +{ + using System.Runtime.Serialization; + + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "99.99.99")] + [System.Runtime.Serialization.DataContractAttribute(Name="BinLibrary", Namespace="http://schemas.datacontract.org/2004/07/BinLib")] + public partial class BinLibrary : object + { + + private string ValueField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public string Value + { + get + { + return this.ValueField; + } + set + { + this.ValueField = value; + } + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "99.99.99")] + [System.Runtime.Serialization.DataContractAttribute(Name="TypeReuseCompositeType", Namespace="http://schemas.datacontract.org/2004/07/TypesLib")] + public partial class TypeReuseCompositeType : object + { + + private bool BoolValueField; + + private string StringValueField; + + [System.Runtime.Serialization.DataMemberAttribute()] + public bool BoolValue + { + get + { + return this.BoolValueField; + } + set + { + this.BoolValueField = value; + } + } + + [System.Runtime.Serialization.DataMemberAttribute()] + public string StringValue + { + get + { + return this.StringValueField; + } + set + { + this.StringValueField = value; + } + } + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "99.99.99")] + [System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference.ITypeReuseSvc")] + public interface ITypeReuseSvc + { + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ITypeReuseSvc/GetData", ReplyAction="http://tempuri.org/ITypeReuseSvc/GetDataResponse")] + System.Threading.Tasks.Task GetDataAsync(int value); + + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ITypeReuseSvc/GetDataUsingDataContract", ReplyAction="http://tempuri.org/ITypeReuseSvc/GetDataUsingDataContractResponse")] + System.Threading.Tasks.Task GetDataUsingDataContractAsync(ServiceReference.TypeReuseCompositeType composite); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "99.99.99")] + public interface ITypeReuseSvcChannel : ServiceReference.ITypeReuseSvc, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "99.99.99")] + public partial class TypeReuseSvcClient : System.ServiceModel.ClientBase, ServiceReference.ITypeReuseSvc + { + + /// + /// Implement this partial method to configure the service endpoint. + /// + /// The endpoint to configure + /// The client credentials + static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials); + + public TypeReuseSvcClient() : + base(TypeReuseSvcClient.GetDefaultBinding(), TypeReuseSvcClient.GetDefaultEndpointAddress()) + { + this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public TypeReuseSvcClient(EndpointConfiguration endpointConfiguration) : + base(TypeReuseSvcClient.GetBindingForEndpoint(endpointConfiguration), TypeReuseSvcClient.GetEndpointAddress(endpointConfiguration)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public TypeReuseSvcClient(EndpointConfiguration endpointConfiguration, string remoteAddress) : + base(TypeReuseSvcClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public TypeReuseSvcClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) : + base(TypeReuseSvcClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public TypeReuseSvcClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public System.Threading.Tasks.Task GetDataAsync(int value) + { + return base.Channel.GetDataAsync(value); + } + + public System.Threading.Tasks.Task GetDataUsingDataContractAsync(ServiceReference.TypeReuseCompositeType composite) + { + return base.Channel.GetDataUsingDataContractAsync(composite); + } + + public virtual System.Threading.Tasks.Task OpenAsync() + { + return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndOpen)); + } + + private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration) + { + if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc)) + { + System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding(); + result.MaxBufferSize = int.MaxValue; + result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max; + result.MaxReceivedMessageSize = int.MaxValue; + result.AllowCookies = true; + return result; + } + throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration)); + } + + private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration) + { + if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc)) + { + return new System.ServiceModel.EndpointAddress("http://localhost:51074/TypeReuseSvc.svc"); + } + throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration)); + } + + private static System.ServiceModel.Channels.Binding GetDefaultBinding() + { + return TypeReuseSvcClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc); + } + + private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress() + { + return TypeReuseSvcClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc); + } + + public enum EndpointConfiguration + { + + BasicHttpBinding_ITypeReuseSvc, + } + } +} \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/ServiceReference/dotnet-svcutil.params.json b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/ServiceReference/dotnet-svcutil.params.json new file mode 100644 index 000000000000..4717a31fe862 --- /dev/null +++ b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/CS/ServiceReference/dotnet-svcutil.params.json @@ -0,0 +1,16 @@ +{ + "providerId": "Microsoft.Tools.ServiceModel.Svcutil", + "version": "99.99.99", + "options": { + "inputs": [ + "../../../../../../src/dotnet-svcutil/lib/tests/TestCases/wsdl/Simple.wsdl" + ], + "language": "CS", + "namespaceMappings": [ + "*, ServiceReference" + ], + "outputFile": "Reference.cs", + "targetFramework": "N.N", + "typeReuseMode": "All" + } +} \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/ServiceReference/Reference.vb b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/ServiceReference/Reference.vb new file mode 100644 index 000000000000..f3f6f2aa933f --- /dev/null +++ b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/ServiceReference/Reference.vb @@ -0,0 +1,167 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + + +Imports System.Runtime.Serialization + +Namespace ServiceReference + + _ + Partial Public Class BinLibrary + Inherits Object + + Private ValueField As String + + _ + Public Property Value() As String + Get + Return Me.ValueField + End Get + Set + Me.ValueField = value + End Set + End Property + End Class + + _ + Partial Public Class TypeReuseCompositeType + Inherits Object + + Private BoolValueField As Boolean + + Private StringValueField As String + + _ + Public Property BoolValue() As Boolean + Get + Return Me.BoolValueField + End Get + Set + Me.BoolValueField = value + End Set + End Property + + _ + Public Property StringValue() As String + Get + Return Me.StringValueField + End Get + Set + Me.StringValueField = value + End Set + End Property + End Class + + _ + Public Interface ITypeReuseSvc + + _ + Function GetDataAsync(ByVal value As Integer) As System.Threading.Tasks.Task(Of ServiceReference.BinLibrary) + + _ + Function GetDataUsingDataContractAsync(ByVal composite As ServiceReference.TypeReuseCompositeType) As System.Threading.Tasks.Task(Of ServiceReference.TypeReuseCompositeType) + End Interface + + _ + Public Interface ITypeReuseSvcChannel + Inherits ServiceReference.ITypeReuseSvc, System.ServiceModel.IClientChannel + End Interface + + _ + Partial Public Class TypeReuseSvcClient + Inherits System.ServiceModel.ClientBase(Of ServiceReference.ITypeReuseSvc) + Implements ServiceReference.ITypeReuseSvc + + ''' + ''' Implement this partial method to configure the service endpoint. + ''' + ''' The endpoint to configure + ''' The client credentials + Partial Private Shared Sub ConfigureEndpoint(ByVal serviceEndpoint As System.ServiceModel.Description.ServiceEndpoint, ByVal clientCredentials As System.ServiceModel.Description.ClientCredentials) + End Sub + + Public Sub New() + MyBase.New(TypeReuseSvcClient.GetDefaultBinding, TypeReuseSvcClient.GetDefaultEndpointAddress) + Me.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc.ToString + ConfigureEndpoint(Me.Endpoint, Me.ClientCredentials) + End Sub + + Public Sub New(ByVal endpointConfiguration As EndpointConfiguration) + MyBase.New(TypeReuseSvcClient.GetBindingForEndpoint(endpointConfiguration), TypeReuseSvcClient.GetEndpointAddress(endpointConfiguration)) + Me.Endpoint.Name = endpointConfiguration.ToString + ConfigureEndpoint(Me.Endpoint, Me.ClientCredentials) + End Sub + + Public Sub New(ByVal endpointConfiguration As EndpointConfiguration, ByVal remoteAddress As String) + MyBase.New(TypeReuseSvcClient.GetBindingForEndpoint(endpointConfiguration), New System.ServiceModel.EndpointAddress(remoteAddress)) + Me.Endpoint.Name = endpointConfiguration.ToString + ConfigureEndpoint(Me.Endpoint, Me.ClientCredentials) + End Sub + + Public Sub New(ByVal endpointConfiguration As EndpointConfiguration, ByVal remoteAddress As System.ServiceModel.EndpointAddress) + MyBase.New(TypeReuseSvcClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) + Me.Endpoint.Name = endpointConfiguration.ToString + ConfigureEndpoint(Me.Endpoint, Me.ClientCredentials) + End Sub + + Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress) + MyBase.New(binding, remoteAddress) + End Sub + + Public Function GetDataAsync(ByVal value As Integer) As System.Threading.Tasks.Task(Of ServiceReference.BinLibrary) Implements ServiceReference.ITypeReuseSvc.GetDataAsync + Return MyBase.Channel.GetDataAsync(value) + End Function + + Public Function GetDataUsingDataContractAsync(ByVal composite As ServiceReference.TypeReuseCompositeType) As System.Threading.Tasks.Task(Of ServiceReference.TypeReuseCompositeType) Implements ServiceReference.ITypeReuseSvc.GetDataUsingDataContractAsync + Return MyBase.Channel.GetDataUsingDataContractAsync(composite) + End Function + + Public Overridable Function OpenAsync() As System.Threading.Tasks.Task + Return System.Threading.Tasks.Task.Factory.FromAsync(CType(Me,System.ServiceModel.ICommunicationObject).BeginOpen(Nothing, Nothing), AddressOf CType(Me,System.ServiceModel.ICommunicationObject).EndOpen) + End Function + + Private Shared Function GetBindingForEndpoint(ByVal endpointConfiguration As EndpointConfiguration) As System.ServiceModel.Channels.Binding + If (endpointConfiguration = EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc) Then + Dim result As System.ServiceModel.BasicHttpBinding = New System.ServiceModel.BasicHttpBinding() + result.MaxBufferSize = Integer.MaxValue + result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max + result.MaxReceivedMessageSize = Integer.MaxValue + result.AllowCookies = true + Return result + End If + Throw New System.InvalidOperationException(String.Format("Could not find endpoint with name '{0}'.", endpointConfiguration)) + End Function + + Private Shared Function GetEndpointAddress(ByVal endpointConfiguration As EndpointConfiguration) As System.ServiceModel.EndpointAddress + If (endpointConfiguration = EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc) Then + Return New System.ServiceModel.EndpointAddress("http://localhost:51074/TypeReuseSvc.svc") + End If + Throw New System.InvalidOperationException(String.Format("Could not find endpoint with name '{0}'.", endpointConfiguration)) + End Function + + Private Shared Function GetDefaultBinding() As System.ServiceModel.Channels.Binding + Return TypeReuseSvcClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc) + End Function + + Private Shared Function GetDefaultEndpointAddress() As System.ServiceModel.EndpointAddress + Return TypeReuseSvcClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_ITypeReuseSvc) + End Function + + Public Enum EndpointConfiguration + + BasicHttpBinding_ITypeReuseSvc + End Enum + End Class +End Namespace \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/ServiceReference/dotnet-svcutil.params.json b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/ServiceReference/dotnet-svcutil.params.json new file mode 100644 index 000000000000..3a76730a2111 --- /dev/null +++ b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/ServiceReference/dotnet-svcutil.params.json @@ -0,0 +1,16 @@ +{ + "providerId": "Microsoft.Tools.ServiceModel.Svcutil", + "version": "99.99.99", + "options": { + "inputs": [ + "../../../../../../src/dotnet-svcutil/lib/tests/TestCases/wsdl/Simple.wsdl" + ], + "language": "VB", + "namespaceMappings": [ + "*, ServiceReference" + ], + "outputFile": "Reference.vb", + "targetFramework": "N.N", + "typeReuseMode": "All" + } +} \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/VB.csproj b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/VB.csproj new file mode 100644 index 000000000000..346742f0a5fc --- /dev/null +++ b/src/dotnet-svcutil/lib/tests/Baselines/LanguageOption/VB/VB.csproj @@ -0,0 +1,16 @@ + + + + Exe + N.N + enable + enable + + + + + + + + + \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/tests/src/GlobalToolTests.cs b/src/dotnet-svcutil/lib/tests/src/GlobalToolTests.cs index 1601496f55fd..a7517f7ff10a 100644 --- a/src/dotnet-svcutil/lib/tests/src/GlobalToolTests.cs +++ b/src/dotnet-svcutil/lib/tests/src/GlobalToolTests.cs @@ -42,6 +42,20 @@ public void HelpGlobal(string verbosity) TestGlobalSvcutil(options); } + [Theory] + [Trait("Category", "BVT")] + [InlineData("CS")] + [InlineData("VB")] + public void LanguageOption(string lang) + { + this_TestCaseName = "LanguageOption"; + TestFixture(); + InitializeGlobal(lang); + var wsdlFile = Path.Combine(g_TestCasesDir, "wsdl", "Simple.wsdl"); + var options = $"-l {lang} {wsdlFile}"; + TestGlobalSvcutil(options); + } + [Theory] [Trait("Category", "BVT")] [InlineData("Project", "--toolContext Project -ntr -tf netcoreapp2.0 -nb")] diff --git a/src/dotnet-svcutil/lib/tests/src/TestInit.cs b/src/dotnet-svcutil/lib/tests/src/TestInit.cs index 5ed531c64247..0b459533b7be 100644 --- a/src/dotnet-svcutil/lib/tests/src/TestInit.cs +++ b/src/dotnet-svcutil/lib/tests/src/TestInit.cs @@ -318,7 +318,7 @@ protected string AppendCommonOptions(string options) public static readonly string g_GeneralErrMsg = $"{Environment.NewLine}{Environment.NewLine}Click the Output link for a full report."; // get test case generated files. NOTE: common test project is not considered nor fixed up. - public static readonly string[] g_GeneratedExtensions = new string[] { ".cs", ".log", ".csproj", ".json", ".config", ".wsdl" }; + public static readonly string[] g_GeneratedExtensions = new string[] { ".vb", ".cs", ".log", ".csproj", ".json", ".config", ".wsdl" }; protected void ValidateTest(string options, string workingDir, int exitCode, string outputText, bool expectSuccess = true) {