Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet AIBot Template produce Warnings #13300

Open
ridomin opened this issue Feb 26, 2025 · 4 comments
Open

dotnet AIBot Template produce Warnings #13300

ridomin opened this issue Feb 26, 2025 · 4 comments
Assignees
Labels
needs more info Need user to provide more info no recent activity The issue labeled needs more info gets no reply from issue owner in time TA:Auth Team Area: Auth

Comments

@ridomin
Copy link

ridomin commented Feb 26, 2025

Using the latest TTK in VS.

File->New->Teams->AIBot

Expected

Solution builds with no errors or warnings

Observed

1>D:\code\temp\MyAIBot\MyAIBot\Models\AppState.cs(20,31,20,32): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
1>D:\code\temp\MyAIBot\MyAIBot\Models\AppState.cs(31,31,31,32): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
1>D:\code\temp\MyAIBot\MyAIBot\Program.cs(114,5,117,3): warning ASP0014: Suggest using top level route registrations instead of UseEndpoints (https://aka.ms/aspnet/analyzers)
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs attention This issue needs the attention of a contributor. label Feb 26, 2025
@ridomin
Copy link
Author

ridomin commented Feb 26, 2025

btw, warning ASP0014 also happens in the basic bot template.

Copy link

👋 Hi @ridomin,

Thank you for reporting this issue! We want to let you know that:

⏱️ Our team will personally review your issue
🎯 You can expect a response within 2 business days

✨ This is an AI-generated initial response
🤖 AI-Generated Preliminary Analysis:

The warnings you are encountering are related to the use of nullable reference types and recommended practices for endpoint routing in ASP.NET Core. Let’s address each warning one by one:

  1. CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

    This warning occurs because nullable reference type annotations are being used without enabling nullable context. To resolve this, you need to enable nullable reference types in your project. You can do this by adding the following line at the top of your .cs files or in your project file.

    Solution 1: Enable nullable reference types in .cs files

    #nullable enable

    Solution 2: Enable nullable reference types in the project file
    Open your .csproj file and add the <Nullable> element:

    <PropertyGroup>
      <Nullable>enable</Nullable>
    </PropertyGroup>
  2. ASP0014: Suggest using top level route registrations instead of UseEndpoints

    This warning suggests using top-level route registrations for better readability and maintainability. You can update your Program.cs file to use top-level route registrations.

    Solution: Update Program.cs

    var builder = WebApplication.CreateBuilder(args);
    var app = builder.Build();
    
    // Configure the HTTP request pipeline.
    if (!app.Environment.IsDevelopment())
    {
        app.UseExceptionHandler("/Error");
        app.UseHsts();
    }
    
    app.UseHttpsRedirection();
    app.UseStaticFiles();
    app.UseRouting();
    
    app.UseAuthorization();
    
    // Top-level route registrations
    app.MapControllers();
    app.MapRazorPages();
    
    app.Run();

By applying these solutions, you should be able to resolve the warnings and have a clean build.

References:

If you need further assistance, feel free to ask!


Note: This is an automated first response generated by AI. A human team member will review your issue and provide a more detailed response soon. We appreciate your patience!

@xzf0587
Copy link
Contributor

xzf0587 commented Feb 27, 2025

Hi @ridomin
Thanks for reaching out. It is appreciated to provide your feedbacks. We will fix them in next release in 4/15.

You can refer to https://github.com/OfficeDev/teams-toolkit/pull/13311/files#diff-eced42530232e4878f1405d47a618decb435fc98f742441161a3b273ad811dd9 to fix it manually as well.

@xzf0587 xzf0587 added needs more info Need user to provide more info and removed investigating needs attention This issue needs the attention of a contributor. labels Feb 27, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the no recent activity The issue labeled needs more info gets no reply from issue owner in time label Mar 7, 2025
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Need user to provide more info no recent activity The issue labeled needs more info gets no reply from issue owner in time TA:Auth Team Area: Auth
Projects
None yet
Development

No branches or pull requests

3 participants