Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How Might C# 7 Look Like?

New C# language constructs currently in development, which might be included in C# 7

  • Login to see the comments

  • Be the first to like this

How Might C# 7 Look Like?

  1. 1. Kakšen bo morda C# 7.0? Damir Arh, Razum d.o.o. Microsoft MVP @DamirArh http://www.damirscorner.com
  2. 2. Agenda
  3. 3. Prevajalnik kot storitev Formatter Colorizer Outlining NavigateTo Object Browser Completion List FindAll References Rename QuickInfo Signature Help Extract Method GoTo Definition Editand Continue Syntax Tree API Symbol API Binding and Analysis API Emit API Parser Symbols Binder IL Emitter Metadata Import Izvorna koda Language Service Compiler API Compiler Pipeline
  4. 4. Uporaba v Visual Studiu 2015
  5. 5. Hitrejši nadaljnji razvoj Visual Studio 2015 Update 1 Interaktivno okno Iskanje implementacij Izboljšave statične analize kode Visual Studio Update 2 Interaktivno okno za projekt Mehko iskanje razredov Deterministično prevajanje kode Visual Studio „15“ Preview Uveljavljanje definiranega sloga izvorne kode Spreminjanje datotek XAML med izvajanjem aplikacije Eksperimentalne razširitve C#
  6. 6. Uporaba v drugih projektih
  7. 7. Kratka zgodovina C# Generiki (2005) LINQ (2007) dynamic (2010) async (2012) Roslyn (2015)
  8. 8. Ključne teme C# 7.0
  9. 9. Ujemanje vzorcev Objektno usmerjeni jeziki Funkcionalni jeziki
  10. 10. Ujemanje vzorcev Visual Studio „15“ Preview
  11. 11. Kaj smo videli?
  12. 12. Stavek „switch“ v izrazu static State Request(this State state, Transition transition) => (state, transition) match ( case (State.Running, Transition.Suspend): State.Suspended case (State.Suspended, Transition.Resume): State.Running case (State.Suspended, Transition.Terminate): State.NotRunning case (State.NotRunning, Transition.Activate): State.Running case *: throw new InvalidOperationException() );
  13. 13. Terke public (int weight, int count) Stocktake(IEnumerable<IWeapon> weapons) { var w = 0; var c = 0; foreach (var weapon in weapons) { w += weapon.Weight; c++; } return (w, c); }
  14. 14. public class Sword(int Damage, int Durability);public class Sword : IEquatable<Sword> { public int Damage { get; } public int Durability { get; } public Sword(int Damage, int Durability); public bool Equals(Sword other); public override bool Equals(object other); public override int GetHashCode(); public static void operator is(Sword self, out int Damage, out int Durability); public Sword With(int Damage = this.Damage, int Durability = this.Durability); } Zapisi
  15. 15. Nespremenljivi razredi IWeapon new Sword IWeapon with public int this int this new IWeapon
  16. 16. Varna uporaba neobveznih vrednosti IWeapon IWeapon null // no warning null // warning // warning
  17. 17. Lokalne funkcije static void ReduceMagicalEffects(this IWeapon weapon, int timePassed) { double decayRate = CalculateDecayRate(); double GetRemainingEffect(double currentEffect) => currentEffect * Math.Pow(decayRate, timePassed); weapon.FireEffect = GetRemainingEffect(weapon.FireEffect); weapon.IceEffect = GetRemainingEffect(weapon.IceEffect); weapon.LightningEffect = GetRemainingEffect(weapon.LightningEffect); }
  18. 18. Rezultati funkcij in spremenljivke po referenci [Test] public void LocalVariableByReference() { var terrain = Terrain.Get(); ref TerrainType terrainType = ref terrain.GetAt(4, 2); Assert.AreEqual(TerrainType.Grass, terrainType); // modify enum value at the original location terrain.BurnAt(4, 2); // local value was also affected Assert.AreEqual(TerrainType.Dirt, terrainType); } public ref TerrainType GetAt(int x, int y) => ref terrain[x, y];
  19. 19. Rezine var array = new int[] { 1, 2, 3, 4, 5 }; var slice = Array.Slice(array, 0, 3); 1 2 3 4 51 2 3array slice
  20. 20. Visual Studio „15“ Preview
  21. 21. Naslednji koraki
  22. 22. DNC Magazine
  23. 23. Viri http://bit.ly/vs15preview https://github.com/dotnet/roslyn http://bit.ly/CsDesignNotes http://bit.ly/BuildRoslyn http://bit.ly/DncRoslynOverview
  24. 24. Izpolnite anketo! Vam je bilo predavanje všeč? Ste se naučili kaj novega? Vaše mnenje nam veliko pomeni! Da bo NT konferenca prihodnje leto še boljša, vas prosimo, da izpolnite anketo o zadovoljstvu, ki jo najdete v svojem NTK spletnem profilu.

×