PrismLibrary / Prism.Maui

This is an experimental repo. The code here will eventually be merged into the main Prism repo as a full fledged platform at which time this repo will be archived.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prism Maui Dependency generates Global Usings

nschoenberg opened this issue · comments

Hi, currently migrating my XF Project and I have the following error message

Error CS8370 Feature 'global using directive' is not available in C# 7.3. Please use language version 10.0 or greater. Futura.IA.CuratedShoppingModule (net6.0) D:\...Futura.IA.CuratedShoppingModule.GlobalUsings.g.cs

My csproj looks like this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <UseMaui>true</UseMaui>
    <TargetFrameworks>net6.0</TargetFrameworks>
    <OutputType>Library</OutputType>
  </PropertyGroup

I can workaround the issue by changing my csproj to this:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <UseMaui>true</UseMaui>
    <TargetFrameworks>net6.0</TargetFrameworks>
    <OutputType>Library</OutputType>
    <ImplicitUsings>disable</ImplicitUsings>
    <LangVersion>10.0</LangVersion>
    <UseMaui>true</UseMaui>
  </PropertyGroup>

Now ... im not sure why I have to add LangVersion to make the error disapear. But when I disable the implicit usings then my msbuild is still creating a global using file with prism namespaces. Is this intended?

global using global::Prism;
global using global::Prism.AppModel;
global using global::Prism.Commands;
global using global::Prism.Events;
global using global::Prism.Ioc;
global using global::Prism.Modularity;
global using global::Prism.Mvvm;
global using global::Prism.Navigation;
global using global::Prism.Regions;
global using global::Prism.Regions.Navigation;
global using global::Prism.Services;

This is probably my fault because I had a Directory.build.props file in my solution folder setting c# version to 7.3. Don't know if that is causing the issue

your issue is 100% self inflicted... you were making a net6.0 library use an older than default language version