question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Considering target C# version

See original GitHub issue

Current code uses C# 6.0. Since the release of MSBuild 15 (and Visual Studio 2017), C# 7.0 is available. Currently project files don’t reflect the existence of a C# version higher than 6.0, still stating ‘default’ in the advanced build properties for ‘Language Version’. We’d gain the following benefits from switching to C# 7.0:

Benefits

  • out variables:
    • You can declare out values inline as arguments to the method where they are used.
  • Tuples
    • You can create lightweight, unnamed types that contain multiple public fields. Compilers and IDE tools understand the semantics of these types.
  • Pattern Matching
    • You can create branching logic based on arbitrary types and values of the members of those types.
  • ref locals and returns
    • Method arguments and local variables can be references to other storage.
  • Local Functions
    • You can nest functions inside other functions to limit their scope and visibility.
  • More expression-bodied members
    • The list of members that can be authored using expressions has grown.
  • throw Expressions
    • You can throw exceptions in code constructs that previously were not allowed because throw was a statement.
  • Generalized async return types
    • Methods declared with the async modifier can return other types in addition to Task and Task<T>.
  • Numeric literal syntax improvements
    • New tokens improve readability for numeric constants.

More info on all these additions can be found on Microsoft’s .NET documentation, from where the short explanation seen in this issue was taken.

Limitations

Support of C# 7.0 is limited. Only MSBuild and roslyn can compile C# 7.0 at this point, and until Mono finishes the switch to MSBuild/roslyn with Mono 5.0, Mono won’t be able to compile. On the Microsoft side of things, the situation is not that much rosier, with only Visual Studio 2017, Visual Studio Code and Visual Studio for Mac being able to handle C# 7.0 natively. VS 2015 can be made to work with C# 7.0, but it is most certainly not a painfree experience, and I am not certain if any of these benefits outweigh the limitations that we’d impose on ourselves.

Scope of the issue

At the moment of writing of this issue, 79 IDE Messages are being generated in Visual Studio 2017 due to a mismatch between the default C# version in Visual Studio 2017 (C# 7.0) and the actual C# version used (C# 6.0), which can be fixed by switching the Language version to explicit 6.0, or to explicit 7.0 and using those C# 7.0 features. Both code in this repository as well as in ppy/osu-framework is affected by this issue, so feel free to move the issue to osu-framework, should the issue be more appropriate over there.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
peppycommented, Apr 15, 2017

Didn’t realise we can explicitly force 6. We should be doing this until mono 5.0 is officially out.

0reactions
Nabile-Rahmanicommented, Apr 15, 2017

They’re called anonymous types.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GNU make drops target in implicit rule?
Found an implicit rule for `A1B/C'. Considering target file `E.1'. File `E.1' does not exist. Finished prerequisites of target file `E.1'.
Read more >
CMake and C++11 on MacOS -- Set your variables before ...
It expects all properties related to a target before you declare that target with add_executable or add_library . I have updated the CMakeLists....
Read more >
Enabling C++11 And Later In CMake
The CXX_STANDARD target property mostly behaves as you would expect. It results in adding the relevant compiler and linker flags to the target...
Read more >
C_STANDARD — CMake 3.27.3 Documentation
New in version 3.1. The C standard whose features are requested to build this target. This property specifies the C standard whose features...
Read more >
Are there any good reasons to use C instead of C++ ...
Are there any good reasons to use C instead of C++, except maybe unavailable C++ compiler for a target platform, maintaining legacy code,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found