Skip to content

Add-Type: add CSharpVersion7 #3853

Closed
Closed

Description

@iSazonov

Should we add new CSharpVersion7 option in Language enum in Add-Type cmdlet?

And why we use "#if CORECLR" in the enum?

Activity

  1. added
    Issue-Question
    on May 24, 2017
  2. lzybkr commented on May 30, 2017

    @lzybkr
    Contributor

    If it works, then yeah.

    Windows PowerShell relies on CodeDom instead of Roslyn for Add-Type, so there are differences, mostly CodeDom isn't updated.

  3. iSazonov commented on May 31, 2017

    @iSazonov
    CollaboratorAuthor

    It seems we already have microsoft.codeanalysis.csharp-2.0.0 and microsoft.codeanalysis.csharp-2.0.0 (last version of the packages is 2.2.0 /cc Dongbo Wang (@daxian-dbw) -Should we update? ) and the next works well:

    $Source = @"
    using System;
    public class BasicTest
    {
    public static void PrintStars(string s) 
    { 
        if (int.TryParse(s, out var i)) { Console.WriteLine(new string('*', i)); } 
        else { Console.WriteLine("Cloudy - no stars tonight!"); } 
    } 
    }
    "@
    Add-Type -TypeDefinition $Source
    
    [BasicTest]::PrintStars("3")
  4. daxian-dbw commented on May 31, 2017

    @daxian-dbw
    Member

    The example above already works in beta.1, so I guess we should add CSharpVersion7 to the enum.
    As for microsoft.codeanalysis.csharp, it will be updated to 2.2.0 with the next refreshment, see PR #3887

  5. added
    Issue-Enhancement
    and removed
    Issue-Question
    on May 31, 2017
  6. iSazonov commented on May 31, 2017

    @iSazonov
    CollaboratorAuthor

    Thanks! Clear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-EnhancementResolution-FixedWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions